How to set an event listener for mx:image to kick in after image loads
Is there a way to dispatch an event after Flex loads an mx:image? I'm loading image e开发者_JAVA技巧xternally and don't know the width/height until it's loaded. I get an exception when I call width/height to the image before loading.
you should use loader, in this case, like i have used in the below mentioned code
private var loader:loader = new Loader();
loader.load(new URLRequest(rp_product.dataProvider[i].@source));
loader.contentLoaderInfo.addEventListener(Event.COMPLETE,productLoadingComplete);
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,productLoadingError);
rp_product.dataProvider[i].@source, here rp_product is my repeater's id,
you simply give the image source here which u want to load, now you have productLoadingComplete() method, and productLoadingError() methods available, even if you want to something on image progess, so use this code :
loader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS,onImageLoadProgress);
in this way, you can load an external image, i hope this is wht u wre luking for
you can attach listener for flash.events.Event.COMPLETE event. it is fired when image loading is complete.
精彩评论