views:

367

answers:

3

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

A: 

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.

dirkgently
A: 

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.

Mark Ingram
A: 

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.

Pat Niemeyer