Animate and form rows, arrays, AS3

Posted by VideoDnd on Stack Overflow See other posts from Stack Overflow or by VideoDnd
Published on 2010-04-09T20:38:46Z Indexed on 2010/04/09 20:43 UTC
Read the original article Hit count: 229

Filed under:
|

Question
How can I animate and form rows together?

Explanation
One 'for loop' is for animation, the other 'for loop' is for making rows. I want to understand how to use arrays and create a row of sprite animations.

'for loop' for animation

//FRAMES ARRAY
//THIS SETS UP MY ANIMATION FOR TIMER EVENT
var frames:Array = [
    new Frame1(),
    new Frame2(),
    new Frame3(),
    new Frame4(),
    new Frame5(),
    new Frame6(),
    new Frame7(),
    new Frame8(),
    new Frame9(),
    new Frame0(),
    ];

for each (var frame:Sprite in frames) {
    addChild(frame);
    }

'for loop' for rows

//THIS MAKES A ROW OF DISPLAY OBJECTS
                    var numberOfClips:Number = 11;
                    var xStart:Number = 0;
                    var yStart:Number = 0;
                    var xVal:Number = xStart;
                    var xOffset:Number = 2;
            for (var $:Number=0; $<numberOfClips; $++)
                    {
//DUDE ARRAY
                    var dude:Array = frames;
                    dude.y = yStart +11;
                    dude.x = xVal +55;
                    xVal = dude.x + dude.width + this.xOffset;
                    }

timer

var timer:Timer = new Timer(100);
timer.addEventListener(TimerEvent.TIMER, countdown);
function countdown(event:TimerEvent) {
    var currentFrame:int = timer.currentCount % frames.length;
    for (var i:int = 0; i < frames.length; ++i) {
        frames[i].visible = (i == currentFrame);
    }
}
timer.start();

counter experiment
My new class I'm working on loops through 10 different display objects that are numbers. For those following, I'm trying to make something like NumbersView.

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3