反射的方法:访问库里的元件的方法
package net.smilecn{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class MainForm extends Sprite{
public function MainForm(){
var ClassReference:Class = getDefinitionByName("Mc1") as Class;
var instance:MovieClip = new ClassReference();
addChild(instance);
}
}
}
package net.smilecn{
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.utils.getDefinitionByName;
public class MainForm extends Sprite{
public function MainForm(){
for(var i=1;i<=2;i++){
var ClassReference:Class = getDefinitionByName("Mc"+i) as Class;
var instance:MovieClip = new ClassReference();
addChild(instance);
}
}
}
}