A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: Looping help Please help me!

  1. #1
    Member
    Join Date
    May 2006
    Posts
    34

    Looping help Please help me!

    ok so what Im dong is looping a movie and it is suposed to loop 3 times then stop. but when I use the script I have the only thing that stops is the main movie. any other movie clips keep animating so I figured I should put the same script inside the movie clip. but it doesnt work. the script im using looks like this

    in the first frame

    onLoad = function(){
    loopCount = 0;
    }

    then in the last frame I put this

    loopCount++;
    if(loopCount == 3){
    stop();
    }

    So my question is in order to get my movie clips to stop after looping three time should I be using a differnt script for the movie clips?
    hellllllllllllllllllllllllllp

  2. #2
    Total Universe Mod jAQUAN's Avatar
    Join Date
    Jul 2000
    Location
    Honolulu
    Posts
    2,429
    1) you dont need to put 'please help me' in your titles, we're here to help.
    2) you dont need a function just to declare a variable, you can just use:
    loopCount = 0;
    That will create a variable and assign an initial value at the same time. But, you will want to say:
    this.loopCount = 0;
    so that each movieclip has their own loopCount to look at.

    Your code for the last frame need only add the this's too.

    Code:
    //frame 1
    this.loopCount = 0;
    
    
    //last frame
    this.loopCount++;
    if(this.loopCount == 3){
      stop();
    }

  3. #3
    Flash Video Moderator Wheels's Avatar
    Join Date
    Dec 2000
    Location
    Minneapolis
    Posts
    1,590
    onLoad is best used with Classes and components, but setting the initial parameter in a function is not a bad idea. If your desire is to loop, and the frame where the parameter is set is crossed, it will reset to 0 - defeating the purpose.

    You could just put everything in one function - and call it on the last frame.


    Code:
    // goes on first frame
    
    function checkLoop(loops:Number):Void
    {
       if (this.loopsCompleted == undefined){
          this.loopsCompleted = 1;
        } else {
          this.loopsCompleted++;
       }
       if (this.loopsCompleted > loops){
          this.stop();
          executeAnotherFunction();
       }
    }
    
    // on last frame
    
    checkLoop(3)
    Last edited by Wheels; 10-07-2006 at 01:08 AM.

  4. #4
    Member
    Join Date
    May 2006
    Posts
    34
    thanks you guys

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