【问题标题】:Actionscript - Event That Notifies When Image Source Has Changed AND is Done LoadingActionscript - 通知图像源已更改并完成加载的事件
【发布时间】:2011-12-08 13:45:52
【问题描述】:

我正在寻找一个在图像的源属性已更改且图像显示对象已加载新数据后触发的事件。我认为“完成”事件是要走的路,但它似乎会在源更改后立即触发,但在图像加载完成之前。在下面的 sn-p 中,我试图在使用 doExport() 中的字节更新 imgMap 后触发 imgMap_completeHandler。

public function doExport(bytes:ByteArray):void
{
    FlexGlobals.topLevelApplication.addElement(this);
    imgMap.source = bytes;
}

protected function imgMap_completeHandler(event:Event):void
{
    var pngEncoder:PNGEncoder = new PNGEncoder();
    var snapShot:ImageSnapshot = ImageSnapshot.captureImage(this,0,pngEncoder);
    export = snapShot.data;
    dispatchEvent(new Event("exportComplete"));
}

<s:Image id="imgMap" complete="imgMap_completeHandler(event)"  width="100%" height="100%"/>

【问题讨论】:

  • 你有没有调用exportComplete的事件/函数
  • 也许 INIT 会起作用。我不熟悉Image组件,但是在许多其他Flash组件中,INIT是在数据更改并且可用后触发的事件。
  • 令人费解。从文档中,听起来这绝对是可行的。另一个要尝试的是ready 事件,但从查看 BitmapImage.as (很多 Image.as 只是这个的包装),似乎就像readycomplete 之前被解雇。
  • 您是否尝试过 updateComplete 的事件处理程序?

标签: actionscript-3 events flex4


【解决方案1】:

您是否尝试过扩展 Image 类和源方法来做到这一点?

您可能只需要在

之后创建一个标准事件
public function source(....)
{
    [super source...]
    dispatchEvent(new Event('Loaded'));
}

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2016-09-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-12-20
    • 1970-01-01
    相关资源
    最近更新 更多