string and z-depth animation, as3

Posted by VideoDnd on Stack Overflow See other posts from Stack Overflow or by VideoDnd
Published on 2010-04-06T14:06:56Z Indexed on 2010/04/06 14:13 UTC
Read the original article Hit count: 167

Filed under:
|

How do I pass this string to my children?

formatCount(fcount) is the value I'm trying to pass to children
timer is the value the children are recieving now

alt text

Timer that loops through an array of displayObjects

var timer:Timer = new Timer(100); 
var count:int = 0;
var fcount:int = 0; 
timer.addEventListener(TimerEvent.TIMER, countdown); 

function countdown(event:TimerEvent) { 
count++; 
fcount=int(count*count/1000);
//myText.text = formatCount(fcount);

//LOOPS THROUGH MY LIST ITEMS 'see array at bottom'
  var currentFrame:int = timer.currentCount % frames.length;
      for (var i:int = 0; i < frames.length; ++i) {
         frames[i].visible = (i == currentFrame);
      }
   }
timer.start();

//SUBSTRING AND ZERO PLACEHOLDER
function formatCount(i:int):String {
  var fraction:int = i % 100;
  var whole:int = i / 100; 

  return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction);
  }

//PASS MATH TO SPRITE HANDLER
function spriteHandler(e:Event):void 
{
  numbers.setTime(formatCount(fcount));
}
//LOST ARGUMENT==>GOES TO NUMBERSVIEW
//var numbers:NumbersView;
var numbers:*;

//MY ARRAY 'list of numbers, one-to-zero'

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);
  }

Example of NumbersView 'increment and place display objects across the stage'

function NumbersView() 
        {
            _listItems = new Array();
            previousNums = new Array();

            var item:NumberImage;
            for (var i:Number = 0; i <= 9; i++) {
                item = new NumberImage();
                addChild(item);
                item.x = i * item.width;
                _listItems.push(item);
            }
        } 

© Stack Overflow or respective owner

Related posts about flash

Related posts about actionscript-3