Flex60460
Flex60460

Reputation: 993

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

Upvotes: 1

Views: 1105

Answers (2)

Dan Monego
Dan Monego

Reputation: 10087

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.

Upvotes: 2

James
James

Reputation: 979

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.

Upvotes: 1

Related Questions