Flash messages were introduced to provide a standard way of displaying status messages to the user. Before that every backend module would display success or error messages in its own way. The transition is not yet complete and some areas still don't use flash messages, but it's definitely the way we're going. Note that all this has nothing to do with Adobe Flash, it's just the way this type of message is called.
Flash messages can either be displayed directly or put into a queue. There's a class called t3lib_FlashMessageQueue which contains a static member variable to store messages. When a BE module is rendered, the template class calls on the queue to retrieve the messages and displays them at the top of the BE module or replaces the ###FLASHMESSAGES### marker, if found in the module's template. Here's a sample code for adding a message to the queue (taken from the Scheduler):
$message = t3lib_div::makeInstance(
't3lib_FlashMessage',
$message,
'',
$severity
);
t3lib_FlashMessageQueue::addMessage($message);
On top of this built-in mechanism, it's possible to use flash messages at your own will inside your BE modules. Just create an instance of a message and ask it to render itself. Here's what such code might look like:
$message = t3lib_div::makeInstance(
't3lib_FlashMessage',
'This is an error message',
'',
t3lib_FlashMessage::ERROR
);
$content .= $message->render();
Note that the t3lib_FlashMessage class defines a number of constants that represent the status level of the message. Available constants are NOTICE, INFO, OK, WARNING and ERROR.
It is perfectly possible to use the flash message class in the frontend too, but the styles for proper rendering will not be defined. They should be added to your web site's stylesheet.