Due tomorrow - IF statement not executing - Stumped

I have an RFID reader scanning tags. The first IF statement works flawlessly with my counter to detect if it should log the item in or out. The 2nd and 3rd don’t work at all. I’ve tried 3 IFs, I’ve tried 1 IF and 2 ELSE IFs, 1 IF, 1 ELSE IF, 1 ELSE…nothing works. This project is due tomorrow and no one else at school has figured it out yet. If anyone can please help I’d really appreciate it. Have a good one!

stop();

/SERIAL SERVER
/java -jar ss6.jar at the command prompt/
createSocket ();

function createSocket () {
_root.createTextField(“rfidLabel”,11,175,105,50,20);
rfidLabel.text = “RFID:”;
rfidLabel.textColor = 0x967296;
_root.createTextField(“loggedLabel”,12,175,135,60,20);
loggedLabel.text = “Logged:”;
loggedLabel.textColor = 0x967296;
_root.createTextField(“designerLabel”,13,175,165,70,20);
designerLabel.text = “Designer:”;
designerLabel.textColor = 0x967296;
_root.createTextField(“garmentLabel”,14,175,195,80,20);
garmentLabel.text = “Garment:”;
garmentLabel.textColor = 0x967296;
_root.createTextField(“materialLabel”,15,175,225,90,20);
materialLabel.text = “Material:”;
materialLabel.textColor = 0x967296;
_root.createTextField(“maintenanceLabel”,16,175,255,100,20);
maintenanceLabel.text = “Maintenance:”;
maintenanceLabel.textColor = 0x967296;
_root.createTextField(“sizeLabel”,17,175,285,110,20);
sizeLabel.text = “Size:”;
sizeLabel.textColor = 0x967296;
_root.createTextField(“colorLabel”,18,175,315,120,20);
colorLabel.text = “Color:”;
colorLabel.textColor = 0x967296;
_root.createTextField(“seasonLabel”,19,175,345,120,20);
seasonLabel.text = “Season:”;
seasonLabel.textColor = 0x967296;
_root.createTextField(“rfidField”,2,250,105,200,20);
_root.createTextField(“loggedField”,3,250,135,200,20);
_root.createTextField(“designerField”,4,250,165,200,20);
_root.createTextField(“garmentField”,5,250,195,200,20);
_root.createTextField(“materialField”,6,250,225,200,20);
_root.createTextField(“maintenanceField”,7,250,255,200,20);
_root.createTextField(“sizeField”,8,250,285,200,20);
_root.createTextField(“colorField”,9,250,315,200,20);
_root.createTextField(“seasonField”,10,250,345,200,20);
rfidField.type = “input”;
rfidField.border = true;
rfidField.background = true;
rfidField.backgroundColor == white;
loggedField.border = true;
loggedField.background = true;
loggedField.backgroundColor == white;
designerField.border = true;
designerField.background = true;
designerField.backgroundColor == white;
garmentField.border = true;
garmentField.background = true;
garmentField.backgroundColor == white;
materialField.border = true;
materialField.background = true;
materialField.backgroundColor == white;
maintenanceField.border = true;
maintenanceField.background = true;
maintenanceField.backgroundColor == white;
sizeField.border = true;
sizeField.background = true;
sizeField.backgroundColor == white;
colorField.border = true;
colorField.background = true;
colorField.backgroundColor == white;
seasonField.border = true;
seasonField.background = true;
seasonField.backgroundColor == white;
serialServer = new XMLSocket ();
trace (“made it” + serialServer);
//127.0.0.1 is the same as localhost
//as discussed with Dave you can investigate remote control via IP later on
serialServer.connect (“127.0.0.1”, 9001);
serialServer.onConnect = function (success) {
trace ("connected " + success);
serialServer.send (“Flash Connection Successful” + new Date().toString());
counter = 0;
};
serialServer.onClose = function () {
trace (“closed”);
};
serialServer.onData = function (data) {
trace ("RFID tag unique ID = " + data);
rfidField.text = data;
//RFID LOGIN/LOGOUT
if (data == 104852495365665569705113){
trace(counter);
if (counter == 0){
trace(“Logged in”);
//DEBUG TRACE
//trace(counter);
loggedField.text = “In”;
designerField.text = “Christian Dior”;
garmentField.text = “Boutique Glam Top”;
materialField.text = “Lycra blend”;
maintenanceField.text = “Wash cold cycle”;
sizeField.text = “M”;
colorField.text = “Black”;
seasonField.text = “Spring”;
dior._alpha = 100;
counter = 1;
}
else if (counter == 1){
trace(“Logged out”);
//DEBUG TRACE
//trace(counter);
loggedField.text = “Out”;
dior._alpha = 0;
counter = 0;
}}
else if (data == 104852495365665465667013){
trace(counter2);
if (counter2 == 0){
trace(“Logged in”);
//DEBUG TRACE
//trace(counter);
loggedField.text = “In2”;
designerField.text = “test2”;
garmentField.text = “test2”;
materialField.text = “test2”;
maintenanceField.text = “test2”;
sizeField.text = “test2”;
colorField.text = “test2”;
seasonField.text = “test2”;
dior._alpha = 100;
counter2 = 1;
}
else if (counter2 == 1){
trace(“Logged out2”);
//DEBUG TRACE
//trace(counter);
loggedField.text = “Out”;
dior._alpha = 0;
counter2 = 0;
}}
else if (data == 104852495365665553485713){
trace(counter3);
if (counter3 == 0){
trace(“Logged in”);
//DEBUG TRACE
//trace(counter);
loggedField.text = “In3”;
designerField.text = “test3”;
garmentField.text = “test3”;
materialField.text = “test3”;
maintenanceField.text = “test3”;
sizeField.text = “test3”;
colorField.text = “test3”;
seasonField.text = “test3”;
dior._alpha = 100;
counter2 = 1;
}
else if (counter3 == 1){
trace(“Logged out3”);
//DEBUG TRACE
//trace(counter);
loggedField.text = “Out3”;
dior._alpha = 0;
counter3 = 0;
}}

};
outputer.onChanged = function () {
serialServer.send (outputer.text);
trace (“output” + outputer.text);
outputer.text = “”;
};
};

Firstly, you have a syntax error with your first and second IF statements because you haven’t closed them with brackets:

//**RFID LOGIN/LOGOUT**
if (data == 104852495365665569705113){
trace(counter);
} // this was missing
if (counter == 0){
trace("Logged in");
} // this was missing
//**DEBUG TRACE**
//trace(counter); 

Secondly, you will probably find that your IF statements still don’t work because AS1.0 and AS2.0 will convert your numbers to a precision of 16 digits. Take a look at this code:

trace(data2);
data3 = 104852495365665553485713;
trace(data3);
/* outputs 
1.04852495365666e+23
1.04852495365665e+23
1.04852495365666e+23
*/

As you can see Flash can’t actually tell the difference between data1, data2 and data3 because they look like the same numbers. The solution is to retrieve your data as a string and then compare it, e.g.

data1 = "104852495365665569705113";
trace(data1);
data2 = "104852495365665465667013";
trace(data2);
data3 = "104852495365665553485713";
trace(data3);
/* outputs 
104852495365665569705113
104852495365665465667013
104852495365665553485713
*/

You can then compare it in the way you’ve tried, e.g.

if (data == "104852495365665569705113") {
do this;
} else if (data == "104852495365665465667013" {
do that;
} else if (data =="104852495365665553485713) {
do something else;
}

Ignore the first comment…because the code wasn’t formatted I didn’t spot the nested brackets lower down. So it looks like your problem is entirely down to the IF statements that are trying to compare numbers that look identical as far as Flash is concerned.