简体   繁体   中英

How do i Load images from a folder into flash AS3?

this is my code:

var my_loader:Loader = new Loader();
my_loader.load(new URLRequest("img/lamp.png"));
addChild(my_loader);

and i want to load it inside a .as file and inside a package instead of inside the actions of my flash file.

how do i change the code?

Not sure if this is what you are asking for, but if you want to embed the images at compile time, you can do this :

[Embed(source="img/lamp.png")]
private var Lamp:Class;

And then to create an instance :

var lamp:Bitmap = new Lamp();

As noted in the comments, this requires compiling with the flex compiler.

If you are using flash pro, you can create library symbols for each image, and then set linkage so they are included at compile time.

Still not sure if this is what you are looking to do.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM