key_str = "";
var str_in:String = "";
key_array = new Array();
data_array = [];
str = "";
function analysis (space:String, obj:XML)
{
var n:Number = 0;
space += "\t";
while (obj.childNodes[n])
{
if (obj.childNodes[n].attributes.depth != "" && obj.childNodes[n].attributes.depth != null)
{
trace(space + "depth : " + obj.childNodes[n].attributes.depth);
if (obj.childNodes[n].attributes.id != "" && obj.childNodes[n].attributes.id != null)
{
key_array[obj.childNodes[n].attributes.depth] = obj.childNodes[n].attributes.id;
trace (space + "id : " + obj.childNodes[n].attributes.id);
str_in = joinId(obj.childNodes[n].attributes.depth);
data_array[str_in] = [];
trace(space + "in : " + str_in);
}
}
if (obj.childNodes[n].nodeName != "" && obj.childNodes[n].nodeName != null)
{
if (obj.childNodes[n].firstChild.nodeValue != "" && obj.childNodes[n].firstChild.nodeValue != null)
{
trace(obj.childNodes[n].attributes.depth + " k1");
var nname:String = obj.childNodes[n].nodeName;
data_array[str_in][nname] = obj.childNodes[n].firstChild.nodeValue;
trace("data : " + str_in + " - " + nname + " - " + data_array[str_in][nname]);
}
}
trace (space + obj.childNodes[n].nodeName + " - " + obj.childNodes[n].firstChild.nodeValue);
str +=space + obj.childNodes[n].attributes.id +"\n"
if (obj.childNodes[n])
{
analysis (space, obj.childNodes[n]);
}
n++;
}
}
function joinId(n)
{
var iid = "";
for (i = 0; i <= n; i++)
{
if (key_array[i])
{
if (i != n)
{
iid += key_array[i] + "_";
}
else
{
iid += key_array[i];
}
}
}
return iid;
}
//
// recursive function to print out the contents of an array similar to the PHP print_r() funciton
//
function print_a( obj, indent ) {
if (indent == null) indent = "";
var out = "";
for ( item in obj ) {
if (typeof( obj[item] ) == "object" )
out += indent+"[" + item + "] => Object\n";
else
out += indent+"[" + item + "] => " + obj[item]+"\n";
out += print_a( obj[item], indent+" " );
}
return out;
}
function display( obj, indent ) {
if (indent == null) indent = "";
var out = "";
var iname = "";
for ( item in obj ) {
if (typeof( obj[item] ) == "object" )
{
iname = item;
trace("this is first : " + iname.substring(0, 1));
if (obj[iname]["enabled"] == "true")
{
_root[iname].gotoAndPlay(2);
//_root[iname]._alpha = 100;
trace(item + " hi " + obj[iname]["enabled"]);
}
else
{
_root[iname].gotoAndStop(1);
//_root[iname]._alpha = 10;
//_root["S_0_0_0_0"]._alpha = 100;
trace(iname + " bye " + obj[iname]["enabled"]);
}
}
out += print_a( obj[item], indent+" " );
}
trace("");
trace(out);
}
var menu_xml:XML = new XML ();
menu_xml.ignoreWhite = true;
menu_xml.onLoad = function (success)
{
if (success)
{
analysis ("", this.childNodes[0]);
//trace(this.childNodes[0]);
//trace(data_array.length);
//trace( print_a( data_array) );
//trace(data_array["S_0_0_0"]["title"]);
display(data_array);
}
};
menu_xml.load ("tree3.xml");
'프로그래밍 언어 > FLASH, FLEX' 카테고리의 다른 글
flex script source 추가 (0) | 2008.04.07 |
---|---|
FLEX 에서 스크롤 (0) | 2008.04.04 |
Complete Flex 3 documentation (0) | 2008.04.03 |
.air web 설치/배포 (0) | 2008.04.03 |
foreach 문 (0) | 2007.12.27 |