skojdk
June 26, 2008, 9:13am
1
is it possible to do this? And if so how? :hat:
the xml is converted to an Object using XLEFF;
there are five nodes en the specified path:
var path:String = “mCb.mXMLloaderObj.dm.lang[0].menu[0].node.length”;
trace(path)
this will offcourse output just the path as a string. But I want to trace something like:
trace(Object(path)); and hopefully get the number 5, which represents how many nodes there are in the specified path in the Object.
Is this possibly? Because I can’t find anyway to do this… Help would be much appreciated as I am on a deadline here…
why are you making a string in the first place?
skojdk
June 26, 2008, 9:24am
3
I’m building an XML based menu system and I need to be able to pass the path to different functions, that’s why I made it a string in the first place. Or is there a more convenient soulution perhaps?
:mario:
well two variables; one string, one not?
why do you want to pass the object_path as a string to different functions?
you want the stuff you get from the path, not the path itself
skojdk
June 26, 2008, 9:47am
5
So I should pass the object I get from the path instead of the path itself you suggest?
Use eval .
var obj:Object = {subobj:{arr:[1,2,3,4,5,6,7]}};
var path:String = "obj.subobj.arr.length";
trace(path);//output obj.subobj.arr.length
trace(eval(path));//output 7
Cheers (-: