As for the layout, I would recommend using ViewStack . You would only need to add each child once, and then just loop through the indices of the stack itself.
You can combine this with Timer , re-run it every time the stack index changes. End the countdown and when the timer ends, increase the selected ViewStack child index. When you hit the last child, reset the index to 0 or do something else.
EDIT: , . , - VBox , ViewStack. , , , ViewStack .
, , Flex, MXML, "startTimer()". , CS4, , , :)
package {
import flash.events.TimerEvent;
import flash.utils.*;
import mx.containers.Box;
import mx.containers.VBox;
import mx.containers.ViewStack;
import mx.controls.Label;
public class StackExample extends Box {
private var stack:ViewStack;
private var timer:Timer;
public function StackExample() {
super();
stack = new ViewStack();
stack.percentHeight = 100;
stack.percentWidth = 100;
for(var i:int=0; i<10; i++) {
stack.addChild(createNewBox(i));
}
stack.selectedIndex = 0;
addChild(stack);
}
public function startTimer():void {
timer = new Timer(1000, 10);
timer.addEventListener(TimerEvent.TIMER, incrementStack, false, 0, true);
timer.start();
}
private function createNewBox(index:int):Box {
var newChildBox:VBox = new VBox();
newChildBox.setStyle("borderStyle", "solid");
var childLabel:Label = new Label();
childLabel.percentWidth = 100;
childLabel.text = "Child: " + index.toString();
childLabel.setStyle("fontWeight", "bold");
newChildBox.addChild(childLabel);
return newChildBox;
}
private function incrementStack(event:TimerEvent):void {
if(stack.selectedIndex < stack.numChildren)
stack.selectedIndex = stack.selectedIndex + 1;
}
}
}