A Flash Developer Resource Site

Results 1 to 8 of 8

Thread: gotoAndStop not working

  1. #1
    Junior Member
    Join Date
    Jun 2010
    Location
    Manchester, UK
    Posts
    25

    gotoAndStop not working

    Hi

    I have what will probably amount to a very small problem: I can't seem to get flash to stop repeating itself with the gotoAndStop function.

    I have 4 frames: on frame 1, I have a button generating a random number from 2 to 4 (only 3 frames, I know). once hit, the button generates the random number and moves to said frame. No problems until the animation on the frame just endlessly loops.

    I've got stop(); on each of the 3 frames in question, I'm using the gotoAndStop command in frame 1 when calling the random frame into play. I'm a total n00b with Flash and AS, and I'm sorry if this is a really daft question, but how do I get it to stop once the movieclip has played?

    Thanks in advance

  2. #2
    Senior Member
    Join Date
    Sep 2008
    Posts
    121
    So you have a movieclip on each frame? and when you get to one of those frames the animation inside that movieclip is repeatedly begin played? Just add a stop() at the end of the animation inside that movieclip then.

  3. #3
    Junior Member
    Join Date
    Jun 2010
    Location
    Manchester, UK
    Posts
    25
    thanks for the reply Geneve, I'm trying it as I type... and you are amazing!!! I didn't think to go into the movieclip and THEN add the stop at the last frame of the actual clip. Duh!

    Once again, thank you so much for the help

  4. #4
    Senior Member
    Join Date
    Sep 2008
    Posts
    121
    Nice

  5. #5
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    Alternately you could have checked from -outside- the MovieClip to see if it was finished playing:

    Code:
    // AS2 syntax
    if (MC1._currentframe == MC1._totalframes) {
         MC1.stop();
    }
    ...but at least you fixed your problem.
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  6. #6
    Senior Member bluemagica's Avatar
    Join Date
    Jun 2008
    Posts
    766
    that code is logically correct, but for me sometimes it wouldn't fire, as if, a frame has been skipped(enterFrame event)....and hence I personally prefer the option of manually putting the stop() on the last frame.
    If you like me, add me to your friends list .

    PS: looking for spriters and graphics artists for a RPG and an Arcade fighting project. If you can help out, please pm me!

    My Arcade My Blog

    Add me on twitter:

  7. #7
    Pumpkin Carving 2008 ImprisonedPride's Avatar
    Join Date
    Apr 2006
    Location
    Grand Rapids MI
    Posts
    2,377
    I commented on the fact that it's AS2 syntax. I've pretty much forgotten how basic AS2 works. :/
    The 'Boose':
    ASUS Sabertooth P67 TUF
    Intel Core i7-2600K Quad-Core Sandy Bridge 3.4GHz Overclocked to 4.2GHz
    8GB G.Skill Ripjaws 1600 DDR3
    ASUS ENGTX550 TI DC/DI/1GD5 GeForce GTX 550 Ti (Fermi) 1GB 1GDDR5 (Overclocked to 1.1GHz)
    New addition: OCZ Vertex 240GB SATA III SSD
    WEI Score: 7.6

  8. #8
    Junior Member
    Join Date
    Jun 2010
    Location
    Manchester, UK
    Posts
    25
    thanks for the replies guys, I've taken the "easy" way out and just added stop() to the end of each movieclip (I only have 6) and it works a treat.

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