[英]Flex 4 - How to set alternate value for a spark Image control and Spark BitmapImage
How to set alternate value for Image and BitmapImage controls in flex 4 like HTML img tag 如何在Flex 4中为HTML和img标签设置Image和BitmapImage控件的替代值
<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
. 这里的问题是
IOErrorEvent
。 If images not loading correctly it throws IO_ERROR EVENT (might be incorrect path). 如果无法正确加载图像,则会引发IO_ERROR EVENT(可能是错误的路径)。 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)" />
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.