对于具有嵌入内容的图像控件,不会触发完成/进度事件
我有以下 MXML 标记:
<mx:Image id="image" width="100%" height="100%"
source="@Embed('../assets/Test.swf')"
complete="completeHandler(event)"
progress="progressHandler(event)"/>
但由于某种原因,我的completeHandler / ProgressHandler 函数没有被调用。 我需要完整事件的原因是因为我想在图像加载后操作位图数据。 在创建完成时位图数据仍然为空。 为什么这些事件没有触发?
编辑:资产在我的应用程序中正确显示 - 所以我知道资产位于正确的位置(无论如何嵌入保证在编译时)。
I've got the following MXML tag:
<mx:Image id="image" width="100%" height="100%"
source="@Embed('../assets/Test.swf')"
complete="completeHandler(event)"
progress="progressHandler(event)"/>
But for some reason my completeHandler / progressHandler functions aren't being called. The reason I need the complete event is because I want to manipulate the bitmap data once the image has loaded. In creationComplete the bitmap data is still null. Why aren't these events firing?
Edit: The asset is correctly showing in my application - so I know the asset is in the right location (the embed guarantees that at compile time anyway).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
检查您的资产路径。 最有可能的是,swf 不在正确的路径中,或者没有被复制到 debug-build/release-build 目录中的
assets
文件夹中。Check your asset path. Most probably, the swf is not at the right path or is not getting copied to an
assets
folder in the debug-build/release-build directory.因此,您只需将 Event.COMPLETE 侦听器直接添加到 loader.contentLoaderInfo 而不是加载器。 我不敢相信这不是他的文档。
So, you just have to add the Event.COMPLETE listener to the loader.contentLoaderInfo directly instead of to the loader. I can't believe this isn't int he docs.
如果您使用的是嵌入式资源,则宽度/高度属性可立即在源对象上使用:
因此,您必须首先创建源的实例,然后在图像对象上设置源。
If you're using an embedded asset, the width / height properties are available immediately on the source object:
So, you have to create an instance of the source first, then set the source on your image object.
这似乎是这里的预期行为!
从文档中:
所以我认为这部分可以解释为什么在您的示例中没有捕获任何进度事件。
它清楚地表明,在处理嵌入式源时,您应该侦听 READY 事件而不是 COMPLETE 事件;)
That seems to be the expected behavior here!
From the documentation:
So I think this part can explain why no progress events are being caught in your example.
It clearly says that you should listen for READY events instead of COMPLETE when dealing with embedded sources ;)