A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: If animation is playing, DO NOT REPEAT IT

  1. #1
    Member
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    97

    If animation is playing, DO NOT REPEAT IT

    Hi,
    In my game, there's a button. When I click on it, it plays an animation of 10 frames longs. The problem is; if I keep my finger on the button, the animation will bug and stay to frame 1.
    I'd like that the button cannot be pressed before the animation's finish.

    So, here's what I want:
    I press (or release), the animation plays, but if I press during the animation is playing, it doesn't do anything. I have to wait until the animation is finish to re-start it.

    Can you help me?

    I know I have to write something with 'true' and 'false', but I don't know how to write it. I tried a lot of things with some threads of this forum, but I didn't reach anywhere...

    Thank you!

  2. #2
    Run for your life! Phlook's Avatar
    Join Date
    Jul 2003
    Location
    Vancouver, Canada
    Posts
    679
    what code are you currently using on your button?

  3. #3
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Call your animation movie clip "anim_mc" and add this to the first frame inside of it:
    Code:
    _root.playTest = "stopped";
    stop();
    Add this to the second frame:
    Code:
    _root.playTest = "playing";
    Add this to the last frame:
    Code:
    gotoAndStop(1);

    Add this code to the frame where the button is located (on the timeline):
    Code:
    play_btn.onPress = function() {
    	if (_root.playTest == "stopped") {
    		anim_mc.gotoAndPlay(2);
    	}
    };
    Call the button "play_btn" and thats it

  4. #4
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    Are you using a gotoAndPlay() statement? Because if so, I reckon you could fix the problem by using this script on your button instead:

    on (release) {
    _root.whateverMovieClip.play();
    }
    http://www.birchlabs.co.uk/
    You know you want to.

  5. #5
    Senior Member PRadvan's Avatar
    Join Date
    Dec 2004
    Location
    NYC
    Posts
    261
    Quote Originally Posted by VENGEANCE MX
    Are you using a gotoAndPlay() statement? Because if so, I reckon you could fix the problem by using this script on your button instead:

    on (release) {
    _root.whateverMovieClip.play();
    }
    that would work too i guess it all depends on what you're trying to do

  6. #6
    Member
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    97
    Thank you VERY MUCH to all of you! It finally works!

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