以下是我的构建器类, 然而当我试图添加参数时, 当我即时将我的对象添加时, 我发现一个错误, 说我没有默认的构建器。 我基本上想将字符串传递到对象, 但并非所有对象都会得到字符串 。
public function Shortcuts(opencontent:String){
highlight = new shortcuthighlight();
highlight.x = highlight.x - highlight.width/2;
highlight.y = highlight.y - highlight.height/2;
highlight.visible = false;
addChild(highlight);
setChildIndex(highlight,0);
this.addEventListener(MouseEvent.ROLL_OVER, addHighlight);
this.addEventListener(MouseEvent.ROLL_OUT, removeHighlight);
this.addEventListener(MouseEvent.MOUSE_DOWN, dragOn);
this.addEventListener(MouseEvent.MOUSE_UP, dragOff);
}
这就是我如何创造我的东西。
for(var i=0; i<shortcutsArray.length;i++){
var className:Class = getDefinitionByName(shortcutsArray[i][0]) as Class;
var object:Object = new className( hey );
var mc:MovieClip = MovieClip(object);
mc.x = shortcutsArray[i][1];
mc.y= shortcutsArray[i][2];
addChild(mc);
}