A Flash Developer Resource Site

Results 1 to 4 of 4

Thread: [RESOLVED] [fCS3] Why?! Just why?!

  1. #1
    Junior Member
    Join Date
    Aug 2007
    Posts
    9

    resolved [RESOLVED] [fCS3] Why?! Just why?!

    Sorry about the unclearness of the title but that's the question i have been asking myself all day!

    I am making a part in my flash game where you can select the level. I have made an input text box and set the var name to levelinput. Then i made a button and gave it this code:

    Code:
    on(release, keyPress"<Enter>"){
    	if(levelinput.toLowerCase eq "tutorial"){
    		gotoAndStop("Scene 2", "tutorialstart");
    	}else if(levelinput.toLowerCase eq "level1"){
    		gotoAndStop("Scene 3", "hsstart");
    	}else{
    		gotoAndStop("Scene 1", "invalidlvl");
    	}
    }
    for some reason i always get the invalidlvl frame. I would really appreciate some help guys, cos i haven't even done the main part of the game yet, and i don't like moving on while things don't work.


    oh, btw, i made sure the frame labels are correct and used the script assist to confirm it. nothing wrong with the code... I followed a tut on this kind of thing and that didn't work either....

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    1- add parens. String.toLowerCase()
    2- eq is deprecated, use ==
    3- omit the Scene name, use frame labels only

    Code:
    on(release, keyPress"<Enter>"){
    	if(levelinput.toLowerCase() == "tutorial"){
    		gotoAndStop("tutorialstart");
    	}else if(levelinput.toLowerCase() == "level1"){
    		gotoAndStop("hsstart");
    	}else{
    		gotoAndStop("invalidlvl");
    	}
    }

  3. #3
    Nabster
    Join Date
    Dec 2006
    Location
    East England
    Posts
    7
    thanks for the answer, but it still doesn't work. I went through again and checked everything was named correctly... nothing.

    I think the problem is something to do with the input box. when I add actionscript to the frame and say: levelinput = "tutorial", the input box has tutorial written in it. But if i change what it says and press the button it still takes me o the tutorial level... ?
    Last edited by Nabster; 08-16-2007 at 08:59 AM.

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    hmm .. seems to work OK in a test file
    Last edited by a_modified_dog; 11-30-2007 at 10:43 AM.

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