如何为Flex 4中的Image和BitmapImage控件设置备用值,例如HTML img标签
<img src="url" alt="some_text">
但是,如果图像不正确,我想显示备用图像。
是否有可能?
这将为您提供帮助。
这里的要害是IOErrorEvent
。如果无法正确加载图像,则会引发IO_ERROR EVENT(可能是错误的路径)。也知道跨域安全性问题。
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)" />
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句