How do I use a Boolean to control a movie clip? I am trying to create a code input to where if the the 4 dynamic text fields equal a certain code a light is displayed.
the 4 dynamic text fields are labled cv1, cv2, cv3, cv4
there is an UNLOCK button which when pressed makes the light go green if the following numbers are present in the Dynamic Text fields (the numbers are 9337)
so this is my code:
on (release) {
var codeiscorrect:Boolean;
if(cv1==9, cv2==3, cv3==3, cv4==7) {
codeiscorrect=true;
}else{
codeiscorrect=false;
}
}
what code do i need to do this? or is there anywhere where i can learn about Booleans?
on (release) {
var codeiscorrect:Boolean;
if(cv1==9 && cv2==3 && cv3==3 && cv4==7) {
codeiscorrect=true;
_root.gotoAndPlay(2);
}else{
codeiscorrect=false;
}
}
however i have 4 lights (white when off, and green when on). So say if 9336 was entered as the code then three lights would go on. There is a light associated to each digit of the 4 digit pin.
How would i make each light go on if the correct digit is entered?
The way your if statement is structured, all the conditions must be true in order for the code to fire. If you want them to fire individually, seperate each variable into it's own if statement.
i am getting confused. Once the i get the digit right the light goes green. But once i press the unlock button again it goes white even tho the digit is correct. I tried a gotoAndStop but once the digit is wrong it stays green and doesnt go back to its off state which is white.
Ok cheers..now can u explain from scratch exactly what functionality u are looking for and how it should work:
(1) what is supposed to happen when i enter the correct code and click unlock..
(2) what is supposed to happen when i enter the incorrect code and click unlock
(3) when are the lights supposed to be green and when are they supposed to be white?
1) i want the unlock code to unlock a vault and go to a certain level
2) when you enter the incorrect code a sound will happen
3) the light goes green when a correct part of the code has been entered. It
should stay green when the correct digit is present but will stay white if
incorrect digit is present (e.g. not matching 9337)
i hope this explains it well enough for you and thank you for taking a look
Ok ive attached working version of the file. A few points to note:
(1) Ive removed all the actions from within the buttons themselves as this is not good practice. Instead all the code is in frame 1.
(2) Ive given all your textfields instance names t0, t1, t2, t3 and controlling them by their instance names instead of putting a value in the var field in the property panel.(forget that even exists IMO).. also the buttons have been named plus0, plus1, plus2 , plus 3 and well as the minus buttons...
its a good idea to try naming your instances begginning with index 0 rather than 1. this is because is many applications u will be using arrays and since arrays start with index 0, it just makes life easier...
(3) the code in frame 1 can be really compacted and condensed into maybe hafl as many lines by using loops etc(however i have not used loops, because that would make it harder for u to see whats going on)..
anyway hope it helps...
Last edited by silentweed; 08-23-2007 at 09:44 AM.