Skip to main content
Known Participant
March 19, 2013
Answered

help with buttons

  • March 19, 2013
  • 1 reply
  • 289 views

hi

im making a shop in my game and i have a button telling my ship to change its frame but i get this error:

Scene 1, Layer 'as', Frame 3, Line 7 1061: Call to a possibly undefined method gotoAndStop through a reference with static type Class.

and here is the code for it:

stop();
import flash.display.MovieClip;
    import flash.events.MouseEvent;

alien3.addEventListener(MouseEvent.MOUSE_DOWN, mouse1);
function mouse1(e:MouseEvent):void {
Ship.gotoAndStop(2);
}

any help.

This topic is closed to new replies. Start a new post to keep the conversation going.
Correct answer Ned Murphy

It appears you have a class you have named "Ship" and in your code you are trying to tell this class to act like a movieclip.  WHat you probably really want to be doing is something more like...

var ship:Ship = new Ship();

addChild(ship);

function mouse1(e:MouseEvent):void {

     ship.gotoAndStop(2);

}

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
March 19, 2013

It appears you have a class you have named "Ship" and in your code you are trying to tell this class to act like a movieclip.  WHat you probably really want to be doing is something more like...

var ship:Ship = new Ship();

addChild(ship);

function mouse1(e:MouseEvent):void {

     ship.gotoAndStop(2);

}