[AS3] Noob Question about Importing.

12 posts

Flag Post

How can I import (say a pixel art drawing) into AS3 so I can use it as a movable object?

 
Flag Post
Originally posted by Mysterymason:

How can I import (say a pixel art drawing) into AS3 so I can use it as a movable object?

What IDE are you using?

 
Flag Post

Please explain. Sorry, a real noob here. Something Something Environment, yes?

 
Flag Post

Flash CS, Flash Builder, Flash Develop, etc?

 
Flag Post

Adobe Flash CS6.

 
Flag Post

Drag the file into flash.

It’s that easy.

 
Flag Post

Or File>Import>To Library if you want.

Then, drag it from the library onto the stage if you want, or add it through code.

 
Flag Post
Originally posted by feartehstickman:

Or File>Import>To Library if you want.

Then, drag it from the library onto the stage

Or le gasp File>Import>To Stage :O

 
Flag Post

..or copy and paste.

 
Flag Post

Alternatively, If you want to say… Get this realistic to history portrait of George Washington to display on screen.

You could do it entirely programmically.
Just put the “image.jpg” in the same folder or location as the code file that executes the below. Feel free to download the picture for this example and try it yourself.

//Embeds a new image, and gives it a class
[Embed(source="image.jpg")]
var ImageD:Class;

//creates a new BitmapData variable that points to our new classes bitmapData
var imageD:BitmapData = new ImageD().bitmapData;

//creates a new bitmap variable that uses our new bitmapData variable
var image:Bitmap = new Bitmap(imageD);

//we can now add "image" to our stage, move it around with x and y, all that fun stuff.
stage.addChild(image);
 
Flag Post

Point of nitpick: Since it’s the bitmap you want in the end, not the bitmapData, you can contract

//creates a new BitmapData variable that points to our new classes bitmapData
var imageD:BitmapData = new ImageD().bitmapData;

//creates a new bitmap variable that uses our new bitmapData variable
var image:Bitmap = new Bitmap(imageD);

into

var image:Bitmap = new ImageD;
 
Flag Post
Originally posted by Draco18s:
Originally posted by feartehstickman:

Or File>Import>To Library if you want.

Then, drag it from the library onto the stage

Or le gasp File>Import>To Stage :O

Well played sir.