如何将我的计数器连接到我的显示列表?
我有一个计数器和一个 displaylist 工作,但是我需要帮助处理它们之间的所有事情。
尝试解释
我完成了雪花教程。雪球是被叫到舞台的孩子们。当连接到动态变量时,它们会四处移动并看起来像雪。我希望我的计数器可以移动数字。我有一个计数器,我有一个'for循环'将孩子们添加到舞台上。
alt text http://www.ashcraftband.com/myspace/videodnd/so_.jpg
链接到文件 http://sandboxfun.weebly.com/
动作-3
//DISPLAYLIST "puts stuff on stage"
for (var i:int = 0; i < 9; i++) {
var t:MovieClip = new Tee();
t.x = 105 + i * 111;
addChild(t);100
}
//ARRAY
//var o:Object = new Object(); <br>
//var TeeProps:Dictionary= new Dictionary(true); <br>
//var Tees:Array = new Array(); <br>
//TeeProps[t] = o; <br>
//addChild(t); <br>
//Tees.push(t); <br>
//} <br>
//COUNTER drop in "mytext" text field to see it work
var timer:Timer = new Timer(10);
var count:int = 0; //start at -1 if you want the first decimal to be 0
var fcount:int = 100;
timer.addEventListener(TimerEvent.TIMER, incrementCounter);
timer.start();
function incrementCounter(event:TimerEvent) {
count++;
fcount=int(count*count/1000);//starts out slow... then speeds up
// mytext.text = formatCount(fcount);
}
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);
}
我正在重建早期版本用于学习目的。
答案 0 :(得分:0)
我将计数器附加到显示列表。这就像示例,但我更改了 for loop 以显示数字。 http://sandboxfun.weebly.com/
//-------------------------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]);
}
}
}