visibility false,XML,as3

时间:2010-05-13 15:36:20

标签: flash actionscript-3

我正在使用外部XML来设置flash变量。 Alpha工作,但不是可见性。 如何让我的瑞士法郎回应可见度?谢谢。

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
}

输出

.5
false

2 个答案:

答案 0 :(得分:2)

您可以尝试:

bg.visible = (bgV == 'true');

答案 1 :(得分:2)

bgV不是一个布尔值,我不完全确定你可以指望它作为字符串传递,你需要这样做:

bg.visible = (bgV.toString() == 'true');