0
votes

As common users of flash you know that you can export images to a moveclip, doing frame per frame, but thats not very "optimized" way to do it, in C++ my friend who I can't talk with right now, have read a spritesheet and made the movements and everything by it, and since AS2 is basicly C++, that would happen to a similar code to it, but I didn't managed to find it.

The thing I want is to import same sized images from a sprite sheet like this one: http://j.imagehost.org/0829/WoodyGX_0.jpg

They are all same sized images put together that form the sprite sheet, so there is this "algorithm" to read each one and like label it to a action use, but since I don't know that I am asking someone who could tell me the likely algorithm or a way to read that sheet, image per image into my movieclip.

Thanks for now.

2

2 Answers

2
votes

I couldn't resist the urge to quote you:

AS2 is basicly C++

Just because I like it.

Anyway. Yes, you could do it, sort of, but AS2 has a rather limited toolset, so it's going to be difficult. First of all, you would need to use BitmapData.draw() method to create a bitmapdata object containing all pixels of the spritesheet you loaded.

Next, you can choose to either do BitmapData.copyPixels() or BimtapData.draw() (again, you can draw from another bitmapdata, using only a portion of it - you will need to look at the parameter where you are to pass a rectangle and a matrix, to tell it what part exactly to copy.

Lastly, to draw it, you would use MovieClip.beginBitmapFill(bitmapdata), and draw the boundaries to fill with the bitmapdata you already have.

0
votes

To expand on his unpronounceableness's answer, you'll need to load your spirite sheet using a MovieClipLoader. Then, you need to create a BitmapData and draw the pixels from the MovieClip that you loaded into. You can then either use that directly as the source to draw or copyPixels to a BitmapData that is your character, calculating which piece is the pose you want each time, or you can create a number of different BitmapData instances and draw one pose to each. Then you iterate through, drawing all the pixels of one smaller bitmap onto your character each time.