游戏编程 flash.utils.Timer_Flash教程-查字典教程网
游戏编程 flash.utils.Timer
游戏编程 flash.utils.Timer
发布时间:2016-12-28 来源:查字典编辑
摘要:复制代码代码如下:publicfunctionsetNextObject(){nextObject=newTimer(1000+Math.r...

复制代码 代码如下:

public function setNextObject() {

nextObject = new Timer(1000+Math.random()*1000,1);

nextObject.addEventListener(TimerEvent.TIMER_COMPLETE,newObject);

nextObject.start();

}

public function newObject(e:Event) {

var goodObjects:Array = ["Circle1","Circle2"];

var badObjects:Array = ["Square1","Square2"];

if (Math.random() < .5) {

var r:int = Math.floor(Math.random()*goodObjects.length);

var classRef:Class = getDefinitionByName(goodObjects[r]) as Class;

var newObject:MovieClip = new classRef();

newObject.typestr = "good";

} else {

r = Math.floor(Math.random()*badObjects.length);

classRef = getDefinitionByName(badObjects[r]) as Class;

newObject = new classRef();

newObject.typestr = "bad";

}

newObject.x = Math.random()*500;

addChild(newObject);

objects.push(newObject);

setNextObject();

}

var typeName:String = classfullname ;

var packageName:String = typeName.split("::")[1];

var type:Class = Class(getDefinitionByName(typeName));

registerClassAlias(packageName, type);

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新Flash教程学习
    热门Flash教程学习
    网页设计子分类