PDA

View Full Version : problem intializing components on the fly?


toddclare
08-31-2005, 02:52 PM
I have a class that uses a loop to create (n) instances of the loader component, and then tells it to load and resize and scale itself.

I'm having the problem that some of them do not obey the resize / scale commands.

Here is my code:

for (var i:Number = 0; i < __paths.length; i++) {
//create a loader component
__topDepth = this.getNextHighestDepth();
createClassObject(Loader, "view"+ i, __topDepth);
this["view" + i].move(0,0);
this["view" + i].setSize(__width, __height);
this["view" + i].addEventListener("progress", this);
}

I'm suspecting that as the loop progresses, the createClassObject is not able to complete before the move() and setSize() calls fire?

Is there a technique for creating a component on the fly (should I be using createClassObject or is there some other way), and then doing things to it once it is available and ready to be dealt with? I see the doLater() in the manual, but I'm not sure if that's what I need or not...

Thanks! I'm still pretty new to classes and components, so I'm sure I'm missing a simple concept