A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: Just a quikc gotoAndPlay() question.

  1. #1
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13

    Just a quikc gotoAndPlay() question.

    Can gotoAndPlay() be used in if statements?

    see code below:

    Code:
    if(_root.shields == 0){
    		gotoAndPlay("GAMEOVER", 1);
    	}
    The reason i ask is because the code i posted above doesnt send my game to the scene GAMEOVER? and i dont have a clue why ive tracked shields to make sure they do reach 0 which they do but it doesnt send the game to the scene specified?

    any ideas?
    -------------------------------
    One who will rise from the ashes!
    -------------------------------
    -*Phoenix*-

  2. #2
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    Yes they can. Try using this.

    if(_root.shields == 0){
    trace("Game over")
    gotoAndPlay("GAMEOVER", 1);
    }


    That code will make a message appear in the output panel saying 'Game Over' if the shields variable equals 0. If you do not get a message, then its another problem. If you do get the message, try calling the first frame on the scene 'GAMEOVER'

    Also, Its case sensitive.

  3. #3
    Senior Member corky§urprise's Avatar
    Join Date
    Jun 2005
    Posts
    346
    OOh yeah, have you tried

    _root.gotoAndPlay("GAMEOVER",1)


  4. #4
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13
    Ok ive tried that i do get the message so the variable is being read at 0 but it still doesnt change scene?
    -------------------------------
    One who will rise from the ashes!
    -------------------------------
    -*Phoenix*-

  5. #5
    Junior Member
    Join Date
    Mar 2006
    Location
    Gravesend, Kent
    Posts
    13
    And yes i have tried _root. as well that doesnt seem to do anything either?
    -------------------------------
    One who will rise from the ashes!
    -------------------------------
    -*Phoenix*-

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