First copy the desired image into folder of the project, for example I'll name my folder assets.
Add a variable to your class:
private var myImg:Class;
And place your cursor on the row above it. Right mouse button on the image and select Generate Embed Code:

You will get something like this:
[Embed(source="../assets/s1.png")]
private var myImg:Class;
Add this where you want to use the image:
var bitmap:Bitmap = new myImg();
addChild(bitmap);
Easy, isn't it?
nice, but i accustomed to using Visual Studio.
ReplyDeleteand CodeDrive provide development on ACtionScript 3, see http://www.codedrive.com/
I have done this..but in my 3D environment(flashDevelop) i just see a white screen
ReplyDeletewhen I switch back to just color material...it works:
[Embed(source = "assets/cube.png")]
private var cubeBitmap:Class;
used light this:
var materialBitmap:BitmapData = new cubeBitmap();
material = new TextureMaterial(new BitmapTexture(materialBitmap));
however in flash ...import the image to lib, then export for actionscript
(no need to embed)
and the above code works
I though if I just add the embed...the usage wil be same?
can anyone help me?