A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: stop all movies

  1. #1
    Senior Member
    Join Date
    Jun 2001
    Posts
    267

    stop all movies

    I am using the following code to simulate a movie projector experience:

    onClipEvent (enterFrame) {
    _root.line._x=random(500);
    for (i=0; i<=1; i++)
    {
    _root.circle.duplicateMovieClip( "circle"+i, i+1);
    }
    if (i=1){
    i=0;
    }
    }

    I would like this code to stop when a button is pressed (the stop button). Is it possible? If so how can I do it?

  2. #2
    Senior Member
    Join Date
    Apr 2006
    Posts
    1,059
    cant u just make the onpress of the button assign some global boolean value
    ----ON MAIN TIMELINE----
    var stop_BtnPressed:Boolean = false

    --on your stopbutton in its OnPress event or whatever its called

    stop_BtnPressed = true

    --on go button ---
    stop_BtnPressed = false

    --in your clip---


    onClipEvent (enterFrame) {
    if(!stop_BtnPressed){
    _root.line._x=random(500);
    for (i=0; i<=1; i++)
    {
    _root.circle.duplicateMovieClip( "circle"+i, i+1);
    }
    if (i=1){
    i=0;
    }
    }
    }

    [edit] may have to throw a _root or two in there...

  3. #3
    Senior Member
    Join Date
    Jun 2001
    Posts
    267
    Thanks for the reply. It seems like that would work. But it doesn't.

    I did find a way to make this happen though.

    1- I altered the MovieClip to have 3 frames. On frame one the code is: stop();

    frame 2 has:
    _root.line._x=random(500);
    for (i=0; i<=1; i++)
    {
    _root.circle.duplicateMovieClip( "circle"+i, i+1);
    }
    if (i=1){
    i=0;
    }
    for (a=0; a<=1; a++)
    {
    _root.circlea.duplicateMovieClip( "circlea"+a, a+1);
    }
    if (a=1){
    a=0;
    }

    (the original code minus the onClipEvent)

    frame 3 loops back to frame 2.

    2- On the original start button it has:
    on (press) {
    movieactions.play();
    play();
    }

    where movieactions is the name of the MovieClip

    3- On the stop button it has:
    on (press) {
    movieactions.stop();
    stop();
    }

    This effectively pauses the action, which is what I needed.

    If anyone has a better way to do this, like a global stop function, please reply to this post. Thanks for all your time!

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