以下是我的构造函数类,但是当我在实例化对象时尝试添加参数时,我收到一条错误消息,指出我没有默认构造函数。我基本上想将一个字符串传递给对象,但并非所有对象都会得到一个字符串。
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);
}