PDA

View Full Version : Looping through about 10 bitmaps in the library and adding them to stage



Mythic Fr0st
June 3rd, 2007, 07:53 AM
basically, I dont wanna do


var t:Array = []
var bitClass1 = new img1()
t[0] = new Bitmap(bitClass)

that basically gets the image with the class img1, from my library, however I want to do this for 10, without repeating that each time, possibly up to 30-40 images,

its very important I can do something like this


for (i = 0; i<20; i++)
{
var c:Class = new Class("img"+i)
t[i] = new c
}

getting images from 0-19

how can I do this?

omegaxmk2
June 3rd, 2007, 09:44 AM
Try this:



import flash.utils.getDefinitionByName;

var t:Array = [];
for (var i:Number = 0; i < 20; i++) {
var c:Class = getDefinitionByName("img" + i) as Class;
t[i] = new Bitmap(new c(200, 200));
//200 can be set to any width or height you want
}