A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Variable on Main Timeline-If Statement?

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    9

    Question Variable on Main Timeline-If Statement?

    Okay, so in my main timeline, I have this:
    Code:
    gameover = false
    if(follower.hitTest(target))
    {
    	
    
    	gameover=true
    gotoAndStop(2);
    clearInterval(NormEnemy);
    clearInterval(GreenEnemy);
    clearInterval(PacEnemy);
    clearInterval(IshEnemy);
    clearInterval(RainbowEnemy);
    clearInterval(DylEnemy);
    clearInterval(lolEnemy);
    }
    
    if (gameover=false)
    {DestroyEnemy=setInterval(KillEnemy, 10000);
    function KillEnemy () {
    removeMovieClip(follower)
    }
    } else if (gameover=true)
    {{FastKillEnemy=setInterval(FKillEnemy, 1);
    function FKillEnemy () {
    removeMovieClip(follower)}}}
    But for some reason, neither of the functions activate. They worked fine until I added the if statements. Does anybody know what might be causing this? Thanks in advance.

  2. #2
    Member
    Join Date
    Aug 2012
    Posts
    55
    put a double == in your if statements

    e.g. if (gameover == false){

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    9
    Yeah, double == are just for testing a variable's value, right? It still did nothing though. o-o

  4. #4
    Member
    Join Date
    Aug 2012
    Posts
    55
    try putting the functions outside and just calling them. also be sure you include your semi colons at the end of every line!
    and maybe your gameover = false at the top should be var gameover = false;

    so it would be

    var gameover = false;
    if(follower.hitTest(target))
    {
    gameover=true;
    gotoAndStop(2);
    clearInterval(NormEnemy);
    clearInterval(GreenEnemy);
    clearInterval(PacEnemy);
    clearInterval(IshEnemy);
    clearInterval(RainbowEnemy);
    clearInterval(DylEnemy);
    clearInterval(lolEnemy);
    }
    function KillEnemy () {
    removeMovieClip(follower);
    }
    function FKillEnemy () {
    removeMovieClip(follower);
    }
    if (gameover==false){
    DestroyEnemy=setInterval(KillEnemy, 10000);
    KillEnemy ();
    } else if (gameover==true){
    FastKillEnemy=setInterval(FKillEnemy, 1);
    FKillEnemy ();
    }
    Last edited by rachelg; 09-06-2012 at 06:15 AM.

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    9
    try putting the functions outside and just calling them.
    Thank you so much it worked! But I'm pretty sure I can move a few functions by myself. :P Thanks again.
    Last edited by Beocro; 09-06-2012 at 06:18 AM.

  6. #6
    Member
    Join Date
    Aug 2012
    Posts
    55
    great!

Tags for this Thread

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