Search code examples
apache-fleximagemxmlflex3

Complete / Progress events aren't firing for Image control with embedded content


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).


Solution

  • 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.