How to set alternate value for Image and BitmapImage controls in flex 4 like HTML img tag
<img src="url" alt="some_text">
But I want to display alternate image if the image is not correct.
Is it possible?
This will help you.
The catch here is IOErrorEvent
. If images not loading correctly it throws IO_ERROR EVENT (might be incorrect path). Also aware of Cross Domain Security issue.
protected function img_creationCompleteHandler(event:FlexEvent):void
{
img.addEventListener(IOErrorEvent.IO_ERROR, function(event:IOErrorEvent):void
{
img.source = "url";//Make sure it should be Right path;
});
}
<s:Image id="img" toolTip="Hey tooltip here" creationComplete="img_creationCompleteHandler(event)" />