Friday, August 26, 2011

[AS3] error #1061

1061: Call to a possibly undefined method addeventListener through a reference with static type flash.diplay:Stage.

打錯事件的keyword,更正即可 = ="

Bad code:

private function onLoaderComplete(e:Event):void
{
ldr.x = stage.width / 2 -ldr.width / 2;
ldr.y = stage.height / 2 -ldr.height / 2;
ldr.alpha = 0;
Tweener.addTween(ldr, { alpha:1, time:1 } );
this.addChild(ldr);
stage.addeventListener(MouseEvent.CLICK, onStageClick);
}


Good code:

private function onLoaderComplete(e:Event):void
{
ldr.x = stage.width / 2 -ldr.width / 2;
ldr.y = stage.height / 2 -ldr.height / 2;
ldr.alpha = 0;
Tweener.addTween(ldr, { alpha:1, time:1 } );
this.addChild(ldr);
stage.addEventListener(MouseEvent.CLICK, onStageClick);
}

No comments :

Post a Comment