- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 50 000 and 100 000 dollars
- Microlancer Beta Tester
- Community Moderator
- Interviewed on the Envato Notes blog
- Author was Featured
- Bought between 1 and 9 items
- Referred between 50 and 99 users
This is driving me totally insane!
I have a flash file, and I want to pick up a true, false value from XML …
This is what I have so far ( I think I’m to used to using AS3
) Any suggestions on how to fix it?
XMLSettings = new XML();
XMLSettings.load("settings.xml");
XMLSettings.onLoad = XMLFunction;
XMLSettings.ignoreWhite = 1;
function XMLFunction() {
if(XMLSettings.childNodes[0].childNodes[0] == true){
mc._visible = true;
}else if(XMLSettings.childNodes[0].childNodes[0] == false){
mc._visible = false;
}
//trace(XMLSettings.childNodes[0].childNodes[0])
}
The trace brings up the code bellow, which I think is perfectly fine
<mc_visible>false</mc_visible>
But the bar is still visible. I have checked and rechecked all possible methods and nothing works
Any help please?
if (XMLSettings.childNodes[0].childNodes[0] == "true")... with quotes ?
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 50 000 and 100 000 dollars
- Microlancer Beta Tester
- Community Moderator
- Interviewed on the Envato Notes blog
- Author was Featured
- Bought between 1 and 9 items
- Referred between 50 and 99 users
if (XMLSettings.childNodes[0].childNodes[0] == "true")... with quotes ?
Just tried
Doesn’t work. Nothing happens 
For some reason, it will not pick up the node. I have no idea what happened. In AS3 I would use the name of the node directly, but AS2 is a mess 
Still not working 
XMLSettings = new XML();
XMLSettings.load("settings.xml");
XMLSettings.onLoad = XMLFunction;
XMLSettings.ignoreWhite = 1;
function XMLFunction() {
if(XMLSettings.childNodes[0].childNodes[0].childNodes[0] == "true"){
mc._visible = true;
}else if(XMLSettings.childNodes[0].childNodes[0].childNodes[0] == "false"){
mc._visible = false;
}
//trace(XMLSettings.childNodes[0].childNodes[0].childNodes[0])
}
Maybe? And yes i agree, AS2 XML sucks!
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 50 000 and 100 000 dollars
- Microlancer Beta Tester
- Community Moderator
- Interviewed on the Envato Notes blog
- Author was Featured
- Bought between 1 and 9 items
- Referred between 50 and 99 users
XMLSettings = new XML();
XMLSettings.load("settings.xml");
XMLSettings.onLoad = XMLFunction;
XMLSettings.ignoreWhite = 1;
function XMLFunction() {
if(XMLSettings.childNodes[0].childNodes[0].childNodes[0] == "true"){
mc._visible = true;
}else if(XMLSettings.childNodes[0].childNodes[0].childNodes[0] == "false"){
mc._visible = false;
}
//trace(XMLSettings.childNodes[0].childNodes[0].childNodes[0])
}
Maybe? And yes i agree, AS2 XML sucks!
I tried quote-ing it.. nothing happens
I am running out of ideas. Any other way to load booleans from XML ? Any other xml loader styles?
FFS AS2 bites 
I tried quote-ing it.. nothing happensXMLSettings = new XML(); XMLSettings.load("settings.xml"); XMLSettings.onLoad = XMLFunction; XMLSettings.ignoreWhite = 1; function XMLFunction() { if(XMLSettings.childNodes[0].childNodes[0].childNodes[0] == "true"){ mc._visible = true; }else if(XMLSettings.childNodes[0].childNodes[0].childNodes[0] == "false"){ mc._visible = false; } //trace(XMLSettings.childNodes[0].childNodes[0].childNodes[0]) }Maybe? And yes i agree, AS2 XML sucks!![]()
I am running out of ideas. Any other way to load booleans from XML ? Any other xml loader styles?
FFS AS2 bites
![]()
Read the code again, i added an extra childNodes0. When you were tracing it was showing the node name too, adding childNodes0 again should access the data in the node?
A long shot but it might work 
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 50 000 and 100 000 dollars
- Microlancer Beta Tester
- Community Moderator
- Interviewed on the Envato Notes blog
- Author was Featured
- Bought between 1 and 9 items
- Referred between 50 and 99 users
Read the code again, i added an extra childNodes0. When you were tracing it was showing the node name too, adding childNodes0 again should access the data in the node? A long shot but it might work![]()
Yes, It accesses data in the node, but it still doesn’t work. I made a variable this time expressing it as a Boolean, and it still doesn’t work what the ….
check it out
var visibleVar:Boolean= XMLSettings.childNodes[0].childNodes[0].childNodes[0]
if (visibleVar == true){
mc._visible = true
}else if(visibleVar == false){
mc._visible = false
}
Try setting it as a String instead of a boolean var. Then put quotes around true and false in the if/else statement. That should work then.
If you’re getting the values from xml, they’d either be strings or numbers. Sometimes number values can be strings too. But setting it as a boolean value wouldn’t make it work because, you’re getting the String value from xml. Okay, so not rocket scientifically explained, but it makes some sense.
// Shucks—
var visibleVarStr:String= String(XMLSettings.childNodes[0].childNodes[0].childNodes[0]);
var visibleVarBool:Boolean;
if(visibleVarStr == "true") {
visibleVarBool = true;
} else if(visibleVarStr == "false") {
visibleVarBool = false;
}
if (visibleVarBool == true){
mc._visible = true
}else if(visibleVarBool == false){
mc._visible = false
}
A little ‘hacky’ but it should work 
Or with this you could do…
var visibleVarStr:String= String(XMLSettings.childNodes[0].childNodes[0].childNodes[0]);
var visibleVarBool:Boolean;
if(visibleVarStr == "true") {
visibleVarBool = true;
} else if(visibleVarStr == "false") {
visibleVarBool = false;
}
mc._visible = visibleVarBool;
- Has been a member for 4-5 years
- Repeatedly Helped protect Envato Marketplaces against copyright violations
- Sold between 50 000 and 100 000 dollars
- Microlancer Beta Tester
- Community Moderator
- Interviewed on the Envato Notes blog
- Author was Featured
- Bought between 1 and 9 items
- Referred between 50 and 99 users
Try setting it as a String instead of a boolean var. Then put quotes around true and false in the if/else statement. That should work then.If you’re getting the values from xml, they’d either be strings or numbers. Sometimes number values can be strings too. But setting it as a boolean value wouldn’t make it work because, you’re getting the String value from xml. Okay, so not rocket scientifically explained, but it makes some sense.
// Shucks—
Yeap… Did that as well
I even tried
mc._visible = XMLSettings.childNodes[0].childNodes[0].childNodes[0]
Nothing happened 
Is there a god of XML I can ask for help lawl 
