CopyCode The Code is as follows: public function setnextobject (){
Nextobject = new timer (1000 + math. Random () *, 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 );