views:

25

answers:

2

Hey,
I'm using external XML to set flash vars. Alpha works, but not Visibility. How do I get my swf to respond to visibility? Thanks.

XML

<?xml version="1.0" encoding="utf-8"?>
<SESSION>
<BGv TITLE="visible true">false</BGv>
<BGa TITLE="alpha 50 percent">.5</BGa>
</SESSION>

SWF

//LISTEN AND LOAD XML
var myXML:*;
var myLoad:URLLoader = new URLLoader();
myLoad.load(new URLRequest("visible.xml"));
myLoad.addEventListener(Event.COMPLETE, parseXML);
//PARSE XML
function parseXML(e:Event):void {
myXML = new XML(e.target.data);
//MY TEST
var bgA:*;
var bgV:*;
trace(myXML.BGa.text());
trace(myXML.BGv.text());
bgA =(myXML.BGa.text());
bgV =(myXML.BGv.text());
//MY OBJECT
bg.alpha = bgA;//This works great
bg.visible = bgV;//This has no effect
}

OUTPUT

.5
false
+2  A: 

You can try with:

bg.visible = (bgV == 'true');
falomir
@falomir, that works :)
pixelGreaser
+2  A: 

bgV isn't a boolean, and I'm not entirely sure you can count on it comming through as a string either, you'll need to do:

bg.visible = (bgV.toString() == 'true');
quoo
@quoo, wow thanks
pixelGreaser