对于具有嵌入内容的图像控件,不会触发完成/进度事件

发布于 2024-07-15 02:33:51 字数 455 浏览 7 评论 0原文

我有以下 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

噩梦成真你也成魔 2024-07-22 02:33:51

检查您的资产路径。 最有可能的是,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.

青丝拂面 2024-07-22 02:33:51

因此,您只需将 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.

等待我真够勒 2024-07-22 02:33:51

如果您使用的是嵌入式资源,则宽度/高度属性可立即在源对象上使用:

var mySource:Object = new embeddedClass();
m_myWidth = mySource.width;
m_myHeight = mySource.height;
m_image = new Image();
m_image.source = mySource;

因此,您必须首先创建源的实例,然后在图像对象上设置源。

If you're using an embedded asset, the width / height properties are available immediately on the source object:

var mySource:Object = new embeddedClass();
m_myWidth = mySource.width;
m_myHeight = mySource.height;
m_image = new Image();
m_image.source = mySource;

So, you have to create an instance of the source first, then set the source on your image object.

无声无音无过去 2024-07-22 02:33:51

这似乎是这里的预期行为!

从文档中:

不保证调度进度事件。 可以接收完整事件,而不分派任何进度事件。 当加载的内容是本地文件时,可能会发生这种情况。

所以我认为这部分可以解释为什么在您的示例中没有捕获任何进度事件。

内容加载完成时调度。 与完整事件不同,此事件针对所有源类型调度。
请注意,对于通过 Loader 加载的内容,将调度就绪事件和完成事件。
对于其他源类型(例如嵌入),仅调度ready。

它清楚地表明,在处理嵌入式源时,您应该侦听 READY 事件而不是 COMPLETE 事件;)

That seems to be the expected behavior here!

From the documentation:

The progress event is not guaranteed to be dispatched. The complete event may be received, without any progress events being dispatched. This can happen when the loaded content is a local file.

So I think this part can explain why no progress events are being caught in your example.

Dispatched when content loading is complete. Unlike the complete event, this event is dispatched for all source types.
Note that for content loaded via Loader, both ready and complete events are dispatched.
For other source types such as embeds, only ready is dispatched.

It clearly says that you should listen for READY events instead of COMPLETE when dealing with embedded sources ;)

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文