views:

672

answers:

1

While trying to load a Bitmap onto a SWFLoader the Event.COMPLETE event is not being triggered

mySWFLoader.source = new Bitmap(Bitmap(someEvent.content).bitmapData);

but if I use a URL as source the complete event is triggered:

mySWFLoader.source = "http://example.com/123.jpg";

Is there some kind of restriction while using Bitmap as source?

+1  A: 

I believe if you use data that already exists in memory (which your Bitmap would) then no load operation would happen. It should be usable immediately after construction. I know attaching movies in AS2 worked like that. If it was part of the library you could use it right away and no loading events would happen.

Herms
Thanks for that info. But what if I wanted to trigger an Event after setting a Bitmap to it? Is there a straightforward way of doing it?
Yeti
dispatchEvent() is a public method, so you could just build an event and call mySWFLoader.dispatchEvent() with it.
Herms
It worked! Cheers!
Yeti
You could also write a simple extension of SWFLoader that wraps the source setter and have that raise some custom event, but I'm not sure how easy it would be to tell in the setter whether or not the source being set would be ready immediately.
Herms
That sounds like a good idea. The source's data type can be checked and if it's a Bitmap - fire a COMPLETE event. I have created and have been using a subclass of SWFLoader which automatically turns on smoothing once the image is loaded. Guess I'll add this feature too. Thanks for the hint!
Yeti