简体   繁体   English

弯曲破碎的火花图像

[英]flex broken spark image

On my air application, I try to load image like this: 在我的air应用程序上,我尝试像这样加载图像:

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. 与mx:Image ioError属性存在,但我找不到与火花图像相同。 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). 如果您使用的是火花图像控件,则可以使用ioError事件捕获错误并使该值无效(或放置一个占位符图像)。 If you need more granularity than that, or if you're in flex 3, you can use a Loader . 如果您需要的粒度更多,或者使用的是flex 3,则可以使用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. 我不知道Spark Image组件中的任何方法都可以检查其是否存在,但是File类可以。

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 . 然后,此操作的结果可以确定是否将source属性设置为null

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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