A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Loop Problems

  1. #1
    Junior Member
    Join Date
    Feb 2007
    Posts
    11

    Loop Problems

    Hi,

    I want to emulate a random attack. I have been trying to do this by using an animation in a movie clip which begins invisible. I generate a random number and if the number 1 is generated the movie clip is made visible and the animation plays before going invisible again. For some reason the animation doest play correctly but i am not sure how to fix it. I think its something to do with the loop.

    The animation has a stop(); on the last frame and the instance of the movie clip is called attack1_mc

    Any help would be awesome.



    Frame 1 code:

    Code:
    if (attack1==3) { 
    }
    if (attack1==1){
    }
    else { 
       attack1 = 0; 
       attack1_mc._visible = false; 
    } 
    
    //attack1 
    if (attack1 == 1) { 
       attack1_mc._visible = true; 
       attack1_mc.gotoAndPlay(1) 
    } 
    if (attack1 == 3) { 
       attack1_mc._visible = true; 
       attack1_mc.gotoAndPlay(1) 
     _global.life = _global.life-1;
    
    }
    Frame2:

    Code:
    num2 = random(20) 
    
    //'to hit' check 
    if (num2==1) { 
       attack1 = 3 
    } 
    if (num2 ==2) { 
       attack1 = 1 
    }

  2. #2
    Junior Member
    Join Date
    Feb 2007
    Posts
    11
    bump.

    Anyone?

  3. #3
    Senior Member
    Join Date
    Oct 2003
    Location
    NYC
    Posts
    107
    Your stop() action is what's stopping the loop. Your only runs the first frame once.

  4. #4
    Junior Member
    Join Date
    Feb 2007
    Posts
    11
    Oops, i should have said lolz.

    I only want the animation to play through once, but i want it to play through fully.

    It seems to be repeating the first could of frames over and over before playing through fully and dissapearing..

  5. #5
    Senior Member
    Join Date
    Oct 2003
    Location
    NYC
    Posts
    107
    It looks like script is trying to loop, not play once. Oh and I noticed you have the if statement repeated twice for the same condition.

    Is it possible to upload the file?

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