A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Multiple case if statement

  1. #1
    Member
    Join Date
    Nov 2006
    Posts
    93

    Multiple case if statement

    Hey, I have a piece of code seen here:

    Code:
    if (keyPress "<Up>") && (playerYPosition > 1){
    		playerYPosition -= 1;
    } else {
    It doesnt like this, gives me bracket errors. So I tried:

    Code:
    if (keyPress "<Up>" && playerYPosition > 1){
    		playerYPosition -= 1;
    } else {
    Says expected ")" needed, although I have no idea why. In a previous piece of work I've used an if statement like this and it was written in this particular way and it worked fine.

    Any ideas what the problem may be? Thanks?

  2. #2
    Senior Member jweeks123's Avatar
    Join Date
    Mar 2006
    Posts
    1,124
    Post your whole statement with the else,then I should be able to troubleshoot for you.

  3. #3
    Member
    Join Date
    Nov 2006
    Posts
    93
    Code:
    if (keyPress "<Up>" && playerYPosition > 1){
    		playerYPosition -= 1;
    } else {
    
    if (keyPress "<Down>" && playerYPosition < 10){
    		playerYPosition += 1;
    } else {
    
    if (keyPress "<Left>" && playerXPosition > 1){
    		playerXPosition -= 1;
    } else {
    
    if (keyPress "<Right>" && playerXPosition < 10){
    		playerXPosition += 1;
    }

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