AS3#1063:var count mismatch onSym01()期望0,得1

时间:2012-10-27 21:26:47

标签: actionscript-3

我正在尝试在舞台上添加一个符号,但我得到了参数错误。

我的代码:

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 ++;
}

1 个答案:

答案 0 :(得分:1)

类构造函数是否采用任何参数?如果没有从构造函数中删除"s"+num

(new ClassReference("s" + num) as MovieClip); 

应该是:

(new ClassReference() as MovieClip);