我正在尝试在舞台上添加一个符号,但我得到了参数错误。
我的代码:
symHolder.mc.sym01_mc.addEventListener(MouseEvent.MOUSE_DOWN, startDragHandler);
function startDragHandler(event:MouseEvent):void {
var ClassReference:Class = getDefinitionByName("Sym" + event.target.name.charAt(3) + event.target.name.charAt(4)) as Class;
var s:MovieClip = (new ClassReference("s" + num) as MovieClip);
s.x = mouseX;
s.y = mouseY;
toggleSymHolder(null);
addChild(s);
s.name = "s" + num;
stage.addEventListener(MouseEvent.MOUSE_UP, stopDragHandler);
s.startDrag();
s.addEventListener(MouseEvent.MOUSE_DOWN, nextDrag);
num ++;
}
答案 0 :(得分:1)
类构造函数是否采用任何参数?如果没有从构造函数中删除"s"+num
。
(new ClassReference("s" + num) as MovieClip);
应该是:
(new ClassReference() as MovieClip);