ActionScript 3 Error #1061

ActionScript 3 Error #1061: Call to a possibly undefined method addEvent through a reference with static type flash.utils:Timer.

ActionScript 3 Error #1061 Description:
AS3 error 1061 appears when you have misspelled a property or function and have not assigned a value to it. If you haven’t properly typed the Object to begin with you will get AS3 Error 1069. See the examples below. AS3 error 1061 is actually pretty nice to work with because it tells you exactly which method/property didn’t work and it tells you which object it didn’t work on.

Flash / Flex Error 1061 Fix:
Find the object listed in the error and then check the spelling after the dot.

Bad Code 1:

var t:Timer = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick);

Good Code 1:

var t:Timer = new Timer(1000, 60);
t.addEventListener(TimerEvent.TIMER, Tick);

Related ActionScript Error(s):
Flash / Flex Error 1069
– You will get AS3 Error 1069 instead of 1061 if you don’t properly type your object before referencing a property on it. For example var t:Timer = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give error 1061 but var t = new Timer(1000, 60);
t.addEvent(TimerEvent.TIMER, Tick); will give Error 1069.
Flash / Flex Error 1119
The dreaded AS 3 Error 1119
Flash / Flex Error 1056
– This is the error you will get if you try and call a property with a misspelled name in the same way as calling a property with a misspelled name.

Flash / Flex 3 Error #1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObject.

ActionScript 3 Error #1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObject.

ActionScript 3 Error #1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:DisplayObjectContainer.

ActionScript 3 Error #1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:Stage.

Description:
AS3 error 1061 will pop up when you trying to referencee an object from within a function that receives an Event. When you do this it will reference the DisplayObject or if you call out to this.parent rather than event.target.parent it will reference the DisplayObjectContainer which doesn’t have a lot of methods with it.

Fix:
One solution to solve Flex/Flash Error 1061 is to make sure that you are using the event that is passed as the target by using

Bad Code 1:

getStarted_btn.addEventListener(MouseEvent.MOUSE_UP,gotoFrame10 );

function gotoFrame10 (e:MouseEvent)
{
this.parent.gotoAndStop(10);
}

Good Code 1:

getStarted_btn.addEventListener(MouseEvent.MOUSE_UP, gotoFrame10);

function gotoFrame10 (e:MouseEvent)
{
e.target.parent.gotoAndStop(10);
}

This should help you resolve Flash / Flex Error #1061

Thanks and as always Happy Flashing

Curtis J. Morley