dcsimg
A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Stuck on Code, please help!!

  1. #1
    Member
    Join Date
    Jan 2003
    Location
    Houston
    Posts
    73

    Stuck on Code, please help!!

    Hey guys,

    Im having a problem trying to keep a loaded level from reloading and playing over. I have a looped region in my main movie, within this looped region, i have a event that loads a level, _level1 to be exact. The problem is everytime it loops, the event repeats and reloads _level1, then the level1 movie replays, anyone know of a solution?

  2. #2
    Member
    Join Date
    Aug 2003
    Posts
    86
    you can set up a variable that says something like :

    moviePlaying = false;

    then on the part where it is loading the movie in, use an if statement, something like:

    if(moviePlaying = false);{
    loadMovie(yourMovie, clipHolder);
    moviePlaying = true;
    }

    tank.
    if i buy duct tape, the terrorists win..

  3. #3
    Monkey Moderator Lexicon's Avatar
    Join Date
    Jul 2001
    Location
    UK
    Posts
    2,038
    sorry to correct you, but there was a slight error

    the solution is reasonable though.

    Code:
    if(moviePlaying == false){
        loadMovie(yourMovie, clipHolder);
        moviePlaying = true;
    }
    
    // can also be written as
    
    if(!moviePlaying){
        loadMovie(yourMovie, clipHolder);
        moviePlaying = true;
    }
    www.lexicon-design.co.uk
    If we aren't supposed to eat animals, then why are they made of meat?
    If Vegetarians like animals so much, why do they eat all their food?

  4. #4
    Member
    Join Date
    Aug 2003
    Posts
    86
    yes, thanks for the correction...
    oh and by the way, if we were meant to eat meat, how come our teeth are so much smaller than that of a carnivorous animal?

    tank.
    if i buy duct tape, the terrorists win..

  5. #5
    Member
    Join Date
    Jan 2003
    Location
    Houston
    Posts
    73
    can you explain the logic on the code above? I put the following code in my main movie, when it loops, the newslider.swf is still reloading evertime

    if(moviePlaying == false){
    loadMovie("newslider.swf", clipHolder);
    moviePlaying = true;


    Thanks in advanced
    Last edited by dna_hard; 07-14-2004 at 10:08 PM.

  6. #6
    Member
    Join Date
    Aug 2003
    Posts
    86
    if(moviePlaying == false){
    loadMovie("newslider.swf", clipHolder);
    moviePlaying = true;

    what this is doing is when it gets to that spot on the timeline where the above script is triggered, it checks to see if the movie is playing...since we established the variable 'moviePlaying' with a value of 'false', once we hit the frame where the above script is triggered the movie designated will load, and then we set the 'moviePlaying' variable to equal 'true' so that the next time the above script is triggered, 'moviePlaying' will not equal 'false' and thus will not trigger the statement above.

    the reason that your movie may still be playing is if you are looping back to the frame where you establish 'moviePlaying' as 'false'...you should have your movie loop to a place later in the movie after where you establish moviePlaying as false...

    good luck

    tank.
    if i buy duct tape, the terrorists win..

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