Skip navigation
mrtunes
Currently Being Moderated

"constructor functions must be" error

Nov 20, 2011 6:38 PM

Tags: #error #actionscript

i have this code snippet that i originally got from the snippet library, but i'm applying it to a new document. i made a square and converted it to a symbol, then gave an instance name of myMovieClip. i put this actionscript code in the first frame with it:

 

stage.addEventListener(KeyboardEvent.KEY_DOWN, keymoving);

 

 

function keymoving(event:KeyboardEvent):void

{

 

 

          switch (event.keyCode)

          {

                    case Keyboard.UP:

                              {

 

 

                              myMovieClip.y -=5;

                              break;

                              }

                    case Keyboard.DOWN:

                              {

 

 

                              myMovieClip.y +=5;

                              break;

                              }

case Keyboard.LEFT:

                              {

 

 

                              myMovieClip.x -=5;

                              break;

                              }

case Keyboard.RIGHT:

                              {

 

 

                              myMovieClip.x +=5;

                              break;

                              }

 

 

}

}

 

and now i get this error: Constructor functions must be instance methods

 
Replies
  • Currently Being Moderated
    Nov 20, 2011 7:47 PM   in reply to mrtunes

    That error should not be resulting from the code you show.  Is there more information in the error message?

     
    |
    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