A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: gotoAndStop won't play the clip that it goes to

  1. #1
    Junior Member
    Join Date
    Apr 2008

    gotoAndStop won't play the clip that it goes to

    Hi, i have a problem :/

    im making a fighting-style game, and need to make it so that when the left or right button is pressed, the character (which is on frame 1, standing still), switches to frame 2, an animation of him walking. However, with the code i have,

    if (Key.isDown(Key.LEFT)) {
    walk = true;
    wspeed = -walkspeed;
    this._xscale = -100;

    } else if (Key.isDown(Key.RIGHT)) {
    walk = true;
    wspeed = walkspeed;
    this._xscale = 100;

    if (!Key.isDown(Key.RIGHT) and !Key.isDown(Key.LEFT)) {
    walk = false;
    if (crouch) {

    if (walk and !crouch) {
    this._x += wspeed;
    if (this.currentFrame !== 2) {
    this.gotoAndStop(2); }

    (ignore the crouch)

    , the player goes to frame 2 but the animation on frame 2 does not play, instead, it just seems to hang on the first frame.

    any help? thanks!

  2. #2
    Senior Member
    Join Date
    Nov 2005
    dante's inferno
    is the animation a movieclip on frame 2, or does it start on frame 2 to like say end on frame 20? without seeing it, my only answer woiuld be that you are telling the movie to go to and STOP on frame 2. with STOP being the keyword.

    If you have a movieclip on frame 2 that you want to play an animation, on frame two you would have to put: myAnimation_mc.play();

    make sense?

    Like I said, without seeing it, it's hard to tell how it is built.


  3. #3
    Junior Member
    Join Date
    Apr 2008
    =) thanks IMS!

    yes, i meant i had an animation on frame 2.

    i did what you suggested and it worked fine! thanks

  4. #4
    Junior Member
    Join Date
    May 2009
    Just remember to put Stop(); on the last frame of the animation

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