The second equality is when the player did not input anything. How can I translate it in as3 ? Thank you for helping.
if (Number(outputexte.text) !=1111 || Number(outputexte.text)==????)
If you are looking for a value of not-valid Number, there's a method for that: isNaN();
if (Number(outputexte.text) !=1111 || isNaN(Number(outputexte.text)))
If you trace the following when the textfield is empty you'll see why Peter's offering does not work...
trace(Number(outputexte.text));
It outputs a 0, which is a number, so the isNaN function...
trace(isNaN(Number(outputexte.text)));
will output a false result.
You should learn to use the trace() function to troubleshoot and investigate things, it is one of the best tools around for troubleshooting code that doesn't work.
Peter's offering will work well if you do not want to allow anything but numbers to be entered, but you can also just restrict the characters of the textfield to be numeric values to get around that.
Hi
I had to consider the situation in which the player, would stay iddle, without clicking on the buttons. So I had to consider the condition when the textfield is empty. That's why Ned's answer was needed. Thank you for your always welcomed input.
As you can see,1111 is the secret code; so all the other numbers and an empty textfield would send me to another frame, while, 1111 will open the safe..
if (outputexte.length == 0 || Number(outputexte.text) !=1111 )...
I'm not saying the code you have is wrong but logically since your second part of the conditions covers the first part of the conditions, your first part of the conditions is superfluous.
You have
(if the plate is empty) or (if what is on the plate is not banana)
If there's nothing on the plate it's not banana anyway, so that you can just use...
if what is on the plate is not banana
...to cover the situation when the plate is empty. Or better still, you could just use...
if banana is on the plate
So your code can just be
if(outputexte.text == "1111")
![]()
--
Kenneth Kawamoto
North America
Europe, Middle East and Africa
Asia Pacific