Adobe Flex:从位图加载图像时不会触发图像的 Event.COMPLETE
我有一个奇怪的问题。当我设置时,我可以让 Event.COMPLETE 触发
image.source = byteArray;
,但是
当我操作 byteArray - 将其转换为 Bitmap 并使用 image.source 或 image.load 加载它时,位图会正确加载到 Image 组件中;但是 Event.COMPLETE 永远不会触发。这里可能出了什么问题?我也添加了一个完整的事件列表!我的来源如下:
var bmp:Bitmap = scaleBitmapData(bitmapData,280,220);
imgPreview.addEventListener(Event.COMPLETE,onPreviewImageCompleted); // never fires
imgPreview.visible = false;
imgPreview.load(bmp); // does not work with .source either; image is displayed but Event.Complete never fires!
谢谢 苏拉特
I have a weird issue. I can get Event.COMPLETE to fire when I set
image.source = byteArray;
BUT
When I manipulate the byteArray - convert it to Bitmap and use image.source or image.load to load it, the bitmap gets loaded properly into the Image component; BUT Event.COMPLETE never fires. What might be wrong here? I have added an event lister for complete too! My source is as follows:
var bmp:Bitmap = scaleBitmapData(bitmapData,280,220);
imgPreview.addEventListener(Event.COMPLETE,onPreviewImageCompleted); // never fires
imgPreview.visible = false;
imgPreview.load(bmp); // does not work with .source either; image is displayed but Event.Complete never fires!
Thanks
Subrat
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以这里使用的类是 SWFLoader(Image 扩展了 SWFLoader)。如果您传入 ByteArray 或 url,它会添加适当的侦听器。您所做的就是向其提供一个位图,它是一个显示对象。下面是将位图加载到图像中的重要代码:
ByteArray:
a url:
这样您就明白了要点。不要将其转换为位图,您将获得完整的事件。您还可以将 ADDED_TO_STAGE 添加到位图。
So the class in play here is SWFLoader (Image extends SWFLoader). If you passed in the ByteArray or a url than it adds the appropriate listener. What you've done is fed it a Bitmap, which is a display object. Here is the important code that is loading a Bitmap into an Image:
ByteArray:
a url:
So you get the gist here. Don't convert it to a Bitmap and you'll get your complete event. You could also add ADDED_TO_STAGE to your Bitmap.