简体   繁体   中英

flex broken spark image

On my air application, I try to load image like this:

var imAc:Image=new Image();
imAc.source=rootFile+value+"-V-"+label+".png";

Sometimes, image source doesn't exist.

In this case, broken icon appear but if this error appear I'd like to change image source

 imAc.source= null

With mx:Image ioError property exist but I don't find the same with spark image. Do you know how to do that?

Thanks

If you're using a spark image control, the ioError event can be used to trap the error and null out the value (or put up a placeholder image). If you need more granularity than that, or if you're in flex 3, you can use a Loader .

I'm not aware of any methods within the Spark Image component that allow you to check of its existence, but the File class does.

new File("your/file/path").exists

will return whether or not he file is present.

The result of this can then determine whether to set the source property to null .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM