Skip navigation
dahaux
Currently Being Moderated

I have a weird problem.

May 20, 2012 8:28 PM

Tags: #help #error #as3 #3.0 #actionscript #actions #click #mouseevent #addeventlistener #1120

I have a problem that I just can't fix and/or find on the internet.I used to be able to just add an event listener but now I always get this error.

**1120: Access of undefined property click_mouse.

I started a new simple code to show you what I mean.This is my simplified code.

**stage.addEventListener(MouseEvent.CLICK, click_mouse);

I also tried it with SEVERAL other words.I have also tried

**new MouseEvent(click_mouse);

**var click_mouse:MouseEvent;

**import flash.events.*

I ensured that I was publishing it in as3 but other than that I dont know what to say.Oh in my other games where it worked....I typed the same code like for example in one of my games it said

**Button7.addEventListener(MouseEvent.CLICK, clickbutton7);

and I retyped it under it and I got no errors but when I changed it to

**Button7.addEventListener(MouseEvent.CLICK, clickbutton1);

it gave me the same previous error.

 
Replies
  • Currently Being Moderated
    May 21, 2012 4:38 AM   in reply to dahaux

    For the code you show, click_mouse and clickbutton1 need to be functions, not variables or properties.  Based on what you show of their use otherwise it looks like you are not using them properly.  What it should involve would be something like...

     

    // an event listener

    stage.addEventListener(MouseEvent.CLICK, click_mouse);

     

    // the event handler function for the listener

    function click_mouse(evt:MouseEvent):void {

           // do stuff

    }

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points