|
DigitalChar.as
class DigitalChar
{
private var txt:Array;
private var len:Number;
private var textContainer:TextField;
private var tm;
public function DigitalChar(tf:TextField)
{
//trace("Contructing...");
textContainer=tf;
init();
}
public function init()
{
//trace("initaling...");
len=new Number(0);
txt=new Array();
for(var i=48;i<58;i++)
{//0-9
//trace(String.fromCharCode(i));
txt.push(String.fromCharCode(i));
len++;
}
for(var i=64;i<91;i++)
{//@A-Z
txt.push(String.fromCharCode(i));
len++;
}
for(var i=97;i<123;i++)
{//a-z
txt.push(String.fromCharCode(i));
len++;
}
tm=setInterval(this,"changeText",500);
}
private function changeText()
{
//trace("interval running...");
textContainer.text=this.txt[Math.floor(Math.random()*len)];
textContainer.textColor=Math.floor(Math.random()*0x0000ff+0xffffff);
}
public function changeChar(a:Array)
{
len=a.length;
for(var p in a)
txt[p]=a[p];
}
public function setTimeInter(t:Number)
{
clearInterval(tm);
tm=setInterval(this,"changeText",t);
}
}
DigitalWorld.as
class DigitalWorld
{
private var dcArr:Array;
private var textw:Number;
private var texth:Number;
private var pMC:MovieClip;
private var w:Number;
private var h:Number;
public function DigitalWorld(parentMC:MovieClip, thew:Number, theh:Number)
{
w=thew;
h=theh;
pMC=parentMC;
init();
}
private function init()
{
textw=texth=20;
dcArr=new Array();
var dep=0;
for (var j = 0; j<w; j++) {
var tmp = textw*j;
for (var i = 0; i<h; i++) {
pMC.createTextField("txt"+dep, dep, tmp, i*texth, textw, texth);
//this["txt"+i].text
dcArr.push(new DigitalChar(pMC["txt"+dep]));
dcArr[dep++].setTimeInter(Math.floor(Math.random()*40+100));
}
}
}
}
testDigitalWorld.fla
第一帧AS:
_root.createEmptyMovieClip("digital",1);
digital._x=100;
digital._y=100;
var p:DigitalWorld=new DigitalWorld(digital,20,20);
[ 本帖最后由 iptton 于 2006-9-26 01:31 编辑 ] |
|