views:

198

answers:

1

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. I understand how to loop through an Array and create a Sprite for each index of the Array, but I'm having trouble putting my animation in rows.

Output
I got my number animation to play in a single row. When I add the loop to multiply it across the stage, it just blinks while continuing to animate.

'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.


INTENT
- Single Frames
'individual sprites for each number'
- Individual behaviors for Flip, and LED


- Flip
'each object is a flip animation with a number' (can't achieve with NumbersView)
- LED
'each object is independent, allowing for 7-seg led patterns, or motions staggering walk-in effect'
- Odometer
'odometer already achieved, but could achieve the same with tweens for each number'


HOPE TO LEARN
- arrays 'understand how to use and combine arrays'
- for loops 'how to use, and how to follow in a document'
- classes 'at what point do I need to extend it as a class'

alt text

EXAMPLES
LED 'same behavior and layout, but vertical increments'
TLrYH8NC4">http://www.youtube.com/watch?v=_TLrYH8NC4

FLIP NUMBER 'great example of terminal board at airport
http://www.youtube.com/watch?v=fH0Aghm1TNE

ODOMETER 'towards the end of the clip'
http://www.youtube.com/watch?v=DKavhec9fGE

alt text

+1  A: 

Your question is a little better now; I've modified the code I gave you for the Odometer slightly, and put in a small Tween inside an object using the Flash IDE. http://dl.dropbox.com/u/3987391/Odometer_Flip.fla

Look at how little I changed in the code, from the Odometer example. The main thing I added is inside the flipper MovieClip. Inside it is an object called digitHolder, which animates using CS4's 3D rotation tool. Inside digitHolder is the TextField which displays the number.

As for the LED alternative, I imagine you could just use a font which looks like LEDs. Your Youtube link doesn't work, so I can't see what the example is, but I imagine a font would cover you.

debu
I'm glad it helped; hopefully your questions will be better next time too. For splitting String objects (if I've understood what you want to do), you can use a set of functions of the String class, some of which are splice, split and substring. See 'public methods' for String, in the docs, here: http://livedocs.adobe.com/flash/9.0/ActionScriptLangRefV3/
debu
@debu, your answer's acceptable! The if else is powerful.Great idea! It eliminate a lot of hassle. I don't want topost ignorantly anymore, so so please advise, while I RTFM.what would be a good question for splitting the string offto each digit 0000000.00? I see you decided not to use Tweener.
VideoDnd
@debu, Thanks, appreciate it.
VideoDnd
Tweener isn't necessary as I animated on the timeline. In fact, using Tweener to create an animation like that would probably be impossible, unless it now supports 3D rotation tweens.
debu