Be a Supporter!

Pause/Play a movieclip loop?

  • 187 Views
  • 5 Replies
New Topic Respond to this Topic
Rees303
Rees303
  • Member since: Apr. 10, 2005
  • Offline.
Forum Stats
Member
Level 22
Animator
Pause/Play a movieclip loop? 2011-07-05 08:50:17 Reply

I have a moveclip loop which makes these shapes pan across the screen continuously.

I used as2 to make the looping:

onClipEvent (load) {
looping.duplicateMovieClip("colours");
colours._x=looping._x+looping._width;
loopStartxthis._x
loopSpeed=5;
}
onClipEvent (enterFrame) {
if(_root.background.loopStart) {
this._x-=loopSpeed;
if(this._x<=(loopStartx-looping._width) ){
this._x=loopStartx=loopSpeed;
}
}
}

The loop works but I also need a pause and play button to stop the loop, any ideas of what the actionscript is?


BBS Signature
Prid-Outing
Prid-Outing
  • Member since: Aug. 7, 2006
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Pause/Play a movieclip loop? 2011-07-05 12:21:23 Reply

Can you please upload a .FLA file of your file with Dumping Grounds (Newgrounds Upload - My Account->Dumping Grounds->Free File Upload) - and send a link to it, please? That way, it'd be easier, because then I know how your file looks, and can alter ;)

Rees303
Rees303
  • Member since: Apr. 10, 2005
  • Offline.
Forum Stats
Member
Level 22
Animator
Response to Pause/Play a movieclip loop? 2011-07-05 15:57:00 Reply

Movieclip loop

Hey Prid-Outing, this link shows the images that loop using the actionscript above, so any ideas how to pause and play the images?


BBS Signature
Rees303
Rees303
  • Member since: Apr. 10, 2005
  • Offline.
Forum Stats
Member
Level 22
Animator
Response to Pause/Play a movieclip loop? 2011-07-05 16:00:59 Reply

oh wrong link, heres the flash file

Movieloop(flashfile)


BBS Signature
Prid-Outing
Prid-Outing
  • Member since: Aug. 7, 2006
  • Offline.
Forum Stats
Member
Level 14
Blank Slate
Response to Pause/Play a movieclip loop? 2011-07-05 16:52:02 Reply

Make the button you want, and give it this Actionscript:

on(press){
	loopCheck = !loopCheck;
}

With this, we create a boolean variable called loopCheck, and when button is pressed, the opposite of the current value will be set. If the current value of loopCheck Boolean Variable is equals to FALSE, pressing the button will result in changing it to TRUE, and if you press again, it will change back to FALSE. After that, on the code you provided on your first post, add this in the onClipEvent(load) section of the code:

_root.loopCheck = true;

This will make the loop start right off when the SWF file is played. Change it to false, if you want the loop to be stopped when movie is played.

And in the onClipEvent(enterFrame) section of the code, change where it says, from:

if(_root.background.loopStart) {

to

if(_root.background.loopStart && _root.loopCheck == true) {

And that's it. You simply create a Boolean Variable (variable only containing two values, either FALSE or TRUE - and with that, you can change between the two values of the Boolean Variable, and make codes be executed if a specific Boolean Variable is equals to TRUE or FALSE) - Hope this helps you ;)

Rees303
Rees303
  • Member since: Apr. 10, 2005
  • Offline.
Forum Stats
Member
Level 22
Animator
Response to Pause/Play a movieclip loop? 2011-07-05 17:05:05 Reply

Thanks a lot, it worked exactly the way I wanted it to :)


BBS Signature