Skip to main content
Inspiring
December 11, 2012
Question

Alternative for 'embed'?

  • December 11, 2012
  • 1 reply
  • 458 views

For loading external texture-images I use embed, like:

[Embed(source = "../Assets/Textures/GUI.png")] " private static const GUITextureAtlasTexture:Class;

Somewhere I red that the embed-tag makes apps load low, so

now I want to replace this line for embedding this image from

the library, but I don't get it to work.

Something like:

var GUITextureAtlasTexture:Class;

GUITextureAtlasTexture = getDefinitionByName ("AtlasImage") as Class;

?

Isn't GUITextureAtlasTexture (like in the embed-example) not the same as

the linkage-name of an imported asset?

This topic has been closed for replies.

1 reply

Colin Holgate
Inspiring
December 11, 2012

My guess is that using embed is just the same as having a library item that you get a pointer to on startup. If you want to load in an image after launch, you can use a regular Loader to load the image from an external folder. Then in the loader's complete listener you can get its image like this:

private function loaded(e:Event){

var bm:Bitmap = e.target.content as Bitmap;

var bmd:BitmapData = bm.bitmapData;

//then use one of those for your texture.

Mark.fromOP
Inspiring
December 14, 2012

If Colin says something is a certain way he is right. Listen to this man he is wise.