Can someone follow what doing, and show me how to do it correctly? I'm new with strings and arrays. Anything you can suggest would be appreciated.
GOAL
I want script to calling display objects to the stage, and the timer to move images up and down to appear like a scrolling numbers. I start getting sloppy, and mess up passing to Tweener.
THOUGHTS
- An explanation or strategy may be enough, "I've got pretty close on this one"
- There was confusion regarding the Containers and addChildren...looked like arrays
THE CODE "get as far as error with NumbersView and numbers undefined etc"
//-------------------------IMPORT METHODS---------------------------------------
import flash.display.DisplayObject;
import flash.display.MovieClip;
import flash.utils.Dictionary;
import flash.events.Event;
import caurina.transitions.Tweener;
//-----------------------TIMER---------------------------------------
var timer:Timer = new Timer(1000);//
//var timer:Timer;
var count:int = 0;
var fcount:int = 0;
var _listItems:Array = new Array();
var previousNums:Array;
const numHeight:int = 120;
//var numbers:NumbersView;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
//-----------------------COUNTER-CONT-----------------------
function incrementCounter(event:TimerEvent) {
count++;
fcount=int(count*count/1000);//starts out slow... then speeds up
// mytext.text = formatCount(fcount);
NumbersView(1);
//}
//----------------------ZERO PLACE HOLDERS-----------------------
}
function formatCount(i:int):String {
var fraction:int = i % 100;
var whole:int = i / 100;
return ("000000000" + i).substr(-9, 9);
// return ("0000000" + whole).substr(-7, 7) + "." + (fraction < 10 ? "0" + fraction : fraction);
}
//
//----------------------DISPLAY for loop, integer to string "puts numbers on stage"
function NumbersView($n:int):void {
//function NumbersView()//
//{
_listItems = new Array();
previousNums = new Array();
var item:NumberImage;
var offset:int = _listItems.length;
//for (var i:int = 0; i < $n; i++)
for (var i:Number = 0; i < 9; i++)
{
item = new NumberImage();
//item.x = (i + offset) * 9;
//item.y = (i + offset) * 9;
item.x = i * item.width;
_listItems.push(item);
addChild(item);
}
//----------------------SPLIT STRING "pass to Tweener or some other method"---------------
//
function setTime($number:String):void {
var nums:Array = $number.split("");
for (var i:Number = 0; i < nums.length; i++) {
if (nums[i] == NumbersView[i]) continue;
Tweener.removeTweens(NumbersView[i]);
}
The methods were proved separately. "I got a earlier version of the document going, but I need to work through this to understand it."
SYMBOL PROPERTIES
CLASS ImageView
TWEENER
The "caurina" folder needs to be present
ROLLING NUMBERS "SUCCESS loading numbers and connecting to counter"
--------------------------------------------------------------------------------------------
What I did for Debu's example
Placed the movie clip object on stage with two dynamic text fields in it.
Note
Make sure the container is placed on stage, has the two text fileds in it, and everything is given a proper instance name. Also include the caurina folder.
seconds MovieClip symbol with instance name of seconds
firstDigit Dynamic text field with instance name of firstDigit, placed in seconds
secondDigit Dynamic text field with instance name of secondDigit, placed in seconds
Symbol
Un-tick 'Export for ActionScript'
Use 'Name, Class, and Instance' correctly