drpelz
drpelz

Reputation: 811

embed-tag for images - how to use?

I would like to know if I have to dispose an image in AS3/Flex when using the EMBED-tag:

[Embed(source="../../../../../assets/interface/pause/cancel_btn_off.png")]
    public static const CancelOffBtn:Class;

private var cancelOffBtn:Bitmap = new Library.CancelOffBtn();

addChild(cancelOffBtn);

When I addChild this class and remove it via removeChild, do I have to dispose this or is this unnecessary? I just ask because it uses the Bitmap-class and under normal circumstances you have to dispose it for the garbage collector.

Or is there another way to embed images without the Bitmap class? I just ask because I'm new to Flex and have problems embedding my stuff into my game. Thank you very much.

Upvotes: 1

Views: 562

Answers (1)

divillysausages
divillysausages

Reputation: 8053

You can dispose of the Bitmap by calling the dispose() method on the BitmapData and setting cancelOffBtn to null. I don't think there's a way to clear the memory of the embedded image though as it's compiled with the swf itself, but technically you shouldn't need to.

Upvotes: 2

Related Questions