Animate and form rows, arrays, AS3
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 Numb开发者_运维问答ersView.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 http://www.ashcraftband.com/myspace/videodnd/countlite__.jpg
EXAMPLES
LED 'same behavior and layout, but vertical increments' http://www.youtube.com/watch?v=__TLrYH8NC4FLIP NUMBER 'great example of terminal board at airport
http://www.youtube.com/watch?v=fH0Aghm1TNEODOMETER 'towards the end of the clip'
http://www.youtube.com/watch?v=DKavhec9fGEalt text http://www.ashcraftband.com/myspace/videodnd/countlite_.jpg
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.
精彩评论