[英]Flex 4 - How to set alternate value for a spark Image control and Spark BitmapImage
如何在Flex 4中為HTML和img標簽設置Image和BitmapImage控件的替代值
<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)" />
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.