How do you load a folder full of png files to construct an AS3 movie clip?

I see plenty of AS3 examples of loading 1 image file into a 1 frame movieclip, but how can you take a folder full of images, load them and treat each image as an individual frame of a single movieclip?

The essential problem I seem to keep running into is how to create a keyframe during runtime...

Answers


I haven really tried it but maybe if you do something like

mc.addChild(image); mc.nextFrame(); mc.addChild(image2); mc.nextFrame();

Cant tell you for sure that it works though :)

What are you going to use this movieclip for ?


You can't do anything like that, because you can't create keyframes at runtime and when add a child to the MovieClip with code, it wont add it to the current frame, it will just add it to the clip's display list, so what you added dynamically will be on every frame.

You should probably try loading your images and storing them in an array or making an array of movie clips or sprites that each have on image. That way you have all the images in a list of clips, and you can still use those clips and display them however you want in your flash movie.


There is no way to add frames dynamically. What you can do is what __dominic suggests: create a class that mimics a movieclip by managing different frames by storing image data in an array ( or similar technique)

A different approach would be to use a sprite sheet. You can find information about sprite sheets in wikipedia and in this SO post

There are also some implementations available online ( i.e. see spritesheet class ).


Need Your Help

Can I use full text search a row in a table where the condition is an array of values from a select query?

sql sql-server sql-server-2008 full-text-search

I want to create a view and I want to do a full text search of a row using a set of keywords. These keywords exist in a table in the database.

use jquery .length only on visible fields

javascript jquery jquery-ui visibility visible

I have a form that uses javascript to dynamically add fields when an "Add field" button is clicked. Additionally, users can remove fields by pressing a "remove field" button. If a field is remove...