4145 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says

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?

2309 posts
  • Beta Tester
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 6-7 years
  • Referred between 10 and 49 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Sold between 100 and 1 000 dollars
  • United States
theflyingtinman says
if (XMLSettings.childNodes[0].childNodes[0] == "true")
... with quotes ?
4145 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says
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 :(

CreativeAddiction
CreativeAddiction Recent Posts Threads Started
160 posts
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
CreativeAddiction says

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!

4145 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says

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 :|

CreativeAddiction
CreativeAddiction Recent Posts Threads Started
160 posts
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
CreativeAddiction says

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 :|

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 :)

4145 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says
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
    }

118 posts
  • Canada
  • Exclusive Author
  • Has been a member for 3-4 years
  • Sold between 1 000 and 5 000 dollars
mflow_n_shucks says

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—

CreativeAddiction
CreativeAddiction Recent Posts Threads Started
160 posts
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
  • Europe
  • Exclusive Author
  • Has been a member for 3-4 years
  • Referred between 1 and 9 users
  • Sold between 1 000 and 5 000 dollars
CreativeAddiction says
    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;

4145 posts Community Mod Building awesome stuff for your mobile devices!
  • Community Moderator
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Interviewed on the Envato Notes blog
  • Author had a Free File of the Month
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Contributed a Tutorial to a Tuts+ Site
  • Won a Competition
+9 more
Enabled Volunteer moderator says
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 :(

by
by
by
by
by
by