4597 posts Community Mod Building awesome stuff for your mobile devices!
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helps us moderate the forums
  • Has sold $125,000+ on Envato Market
+15 more
Enabled 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
  • Has been part of the Envato Community for over 7 years
  • Has referred 10+ members
  • Has sold $100+ on Envato Market
  • Has been a beta tester for an Envato feature
+5 more
theflyingtinman says
if (XMLSettings.childNodes[0].childNodes[0] == "true")
... with quotes ?
4597 posts Community Mod Building awesome stuff for your mobile devices!
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helps us moderate the forums
  • Has sold $125,000+ on Envato Market
+15 more
Enabled 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
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+3 more
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!

4597 posts Community Mod Building awesome stuff for your mobile devices!
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helps us moderate the forums
  • Has sold $125,000+ on Envato Market
+15 more
Enabled 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
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+3 more
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 :)

4597 posts Community Mod Building awesome stuff for your mobile devices!
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helps us moderate the forums
  • Has sold $125,000+ on Envato Market
+15 more
Enabled 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
  • Has been part of the Envato Community for over 4 years
  • Has sold $1,000+ on Envato Market
  • Located in Canada
  • Sells items exclusively on Envato Market
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
  • Has been part of the Envato Community for over 4 years
  • Has referred 1+ members
  • Has sold $1,000+ on Envato Market
  • Has collected 10+ items on Envato Market
+3 more
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;

4597 posts Community Mod Building awesome stuff for your mobile devices!
  • Contributed a blog post
  • Elite Author: Sold more than $75,000 on Envato Market
  • Helps us moderate the forums
  • Has sold $125,000+ on Envato Market
+15 more
Enabled 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 :(

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by