A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: AS3 gotoAndStop not working on buttons, please help!!

  1. #1
    Junior Member
    Join Date
    May 2005
    Posts
    2

    AS3 gotoAndStop not working on buttons, please help!!

    I'm trying to learn this fancy AS3 jazz and keep getting an error when I do a simple gotoAndStop. Does anyone know what I'm doing wrong?

    Code:

    skipBtn_mc.buttonMode = true;

    skipBtn_mc.addEventListener(MouseEvent.CLICK, skipClick);
    skipBtn_mc.addEventListener(MouseEvent.ROLL_OVER, skipOver);
    skipBtn_mc.addEventListener(MouseEvent.ROLL_OUT, skipOut);

    function skipOver(event:MouseEvent):void
    {
    skipBtn_mc.gotoAndStop("over");
    }

    function skipOut(event:MouseEvent):void
    {
    skipBtn_mc.gotoAndStop("up");
    }

    function skipClick(event:MouseEvent):void
    {
    gotoAndPlay("small");
    }

    Error:

    1061: Call to a possibly undefined method gotoAndStop through a reference with static type flash.display:SimpleButton.

    1119: Access of possibly undefined property buttonMode through a reference with static type flash.display:SimpleButton.

  2. #2
    Senior Member cancerinform's Avatar
    Join Date
    Mar 2002
    Location
    press the picture...
    Posts
    13,449
    You need to use a MovieClip. The SimpleButton class does not have those methods.
    - The right of the People to create Flash movies shall not be infringed. -

  3. #3
    Junior Member
    Join Date
    May 2005
    Posts
    2
    Uh, thanks so much. It was a movie clip, but for some reason in the properties i had it set to Button. THanks!


    Quote Originally Posted by cancerinform
    You need to use a MovieClip. The SimpleButton class does not have those methods.

  4. #4
    Junior Member
    Join Date
    Nov 2007
    Posts
    17
    I figure I'd post my question in this thread, to avoid duplicate threads and such. Anyhow, my question is, how do I write it in AS3 to where a button is released and it goes to another frame? In relation to the rest of this thread, I was using the gotoAndStop() method to do this with Simple Buttons, and it was working for some reason. Now that I am trying to centralize everything to an external .as file, now its giving the error mentioned above. And after looking at the AS3 API, the gotoAndStop() method definitely is not part of the Simple Button class. But why would it work before? When I originally created this FLA file, I specified it as AS3, not AS2, yet it still worked. It wasn't until I took out most of my AS3 code out of the FLA file itself that this error first started to occur.

    I would call an instance name of a button like this:
    code:

    backButton.addEventListener(MouseEvent.MOUSE_DOWN, bringMeBack);
    public function bringMeBack(Event:MouseEvent):void
    {
    gotoAndStop(15);
    }



    But now once I added that syntax to the external .as file, now I get that error. So with that said, how then, do I use a button to take the user to a different frame? The problem with using a movie clip is, there are no mouse events such as up, over, and down.

    I have wrote Java for a couple years now, so the structure and general syntax of AS3 is fairly clear to me, but some specifics of AS itself throws me through a loop every so often...

    Thanks in advance for your help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center