IF statement not working. Seems simple

Hi

I’m building a Flash app with Flash and mProjector, but this is code related, and not caused by mProjector. (90% sure :D)

Anyway, my App is setup like this so far:

1. Open app, form appears. (works)
2. User fills out form, clicks on a button to save form results to XML file on local Hard Drive. Checkboxes are present.
A listener object sits in the background and updates a Text field with the checkboxes status.
The Text fields value is written to the XML file. (works)
3. User presses a button to clear form fields. (works)
4. User clicks open document, navigates to saved XML file and opens it. (works)
5. XML is loaded into Flash. Form fields are filled out. (works)
6. The two Checkboxes, based on two If Statements and the contents of the XML file, are told to be selected, or unselected. (Doesn’t work)

Heres the code for the IF Statements:

if (data_xml.firstChild.childNodes[3].firstChild == "1") {
	check_email.selected = true;
} else if (data_xml.firstChild.childNodes[3].firstChild == "0") {
	check_email.selected = false;
}
		
		
if (data_xml.firstChild.childNodes[4].firstChild = "yes") {
	check_fax.selected = true;
} else if (data_xml.firstChild.childNodes[4].firstChild = "no") {
	check_fax.selected = false;
}

A **Trace of:

"data_xml.firstChild.childNodes[3].firstChild = " + data_xml.firstChild.childNodes[3].firstChild;

Produces: data_xml.firstChild.childNodes[3].firstChild = 1
[SIZE=“1”]** Not real trace. Flashes built-in tracer is out of reach once the Swf is compiled into a mProjector app, and I couldn’t get mProjectors Traceviewer to work for me, so I’m sending my trace commands to a dynamic text field. Seems to work.[/SIZE]

Which confuses me, the Value is obviously “1” the xml file says so, the app says so once its imported. But the If Statement doesn’t care.
If I use “=” in the IF statement, the checkbox is told to be selected, no matter what the loaded XML file says.
If I use “==” in the IF statement, then the checkbox is told to be unselected no matter what the XML file says. (Or is just unresponsive in general. I:E not unselecting it if it was selected on XML load)

Soooo… What kind of mindlessly simple thing am i missing here?
I really didn’t expect bugs from this. Bugs yes, but not from this bit of code.

Since all I have to do is change the code back and forth between “=” and “==” to get the checkboxes to change behavior, I’m positive the problem doesn’t lie in something like variable or instance names.
I get no errors when I check the code in Flash, and I can’t find any loose bits of code or typos that could be the problem.

Any suggestions?

Thanks

  • Lem