Skip to main content
Participating Frequently
January 17, 2013
Answered

1061:call to a possibly undefined method addEventListener through a reference with static type class

  • January 17, 2013
  • 2 replies
  • 2270 views

i have used the code snippets to move from keyframe 1 to 2 with this code it is a button.




/* Stop at This Frame

The Flash timeline will stop/pause at the frame where you insert this code.

Can also be used to stop/pause the timeline of movieclips.

*/

stop();

/* Click to Go to Frame and Stop

Clicking on the specified symbol instance moves the playhead to the specified frame in the timeline and stops the movie.

Can be used on the main timeline or on movie clip timelines.

Instructions:

1. Replace the number 5 in the code below with the frame number you would like the playhead to move to when the symbol instance is clicked.

*/

Playbtn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_6);

function fl_ClickToGoToAndStopAtFrame_6(event:MouseEvent):void

{


gotoAndStop(2);

}

but i get this error, can anyone help?

the error i get if i change the name in the code to the class name instead

1120:Access of undefined property Playbutton

(the instance name is Playbtn)

Thanks for your concern!

This topic has been closed for replies.
Correct answer Ned Murphy

As I said, it is not an uncommon error to start mixing up naming between "btn" and "button"... you've already demonstrated doing it between your first two postings.  If "Playbutton" is the class name, then you cannot assign an event listener to it as you just showed in response 3

2 replies

Ned Murphy
Legend
January 17, 2013

The error is indicating you are trying to assign a method to a Class object rather than a button or movieclip object.  Where is the name "Playbtn" assigned to the button in question?  In the library, do you see that name to the far right of the button under the AS Linkage heading?

If Playbutton is coming up as an undefined property, then it exists somewhere in your code.  It is not an uncommon error to start mixing up naming between "btn" and "button" for object names.

Participating Frequently
January 17, 2013

Playbtn is the instance name
Playbutton is the Class name and the top one in properties

So which error is easier to fix, im still not sure which is the better error if their is such a thing

kglad
Community Expert
Community Expert
January 17, 2013

there's code, other than what you showed, causing at least the 1120 error.

use movie explorer to find all your code.

also, click file>publish settings>swf and tick "permit debugging" to see the line number (and frame) triggering the error messages.

Participating Frequently
January 17, 2013

Playbutton.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_6);

the problem is with this line for 1120

and where is movie explorer?

Ned Murphy
Ned MurphyCorrect answer
Legend
January 17, 2013

As I said, it is not an uncommon error to start mixing up naming between "btn" and "button"... you've already demonstrated doing it between your first two postings.  If "Playbutton" is the class name, then you cannot assign an event listener to it as you just showed in response 3