You probably should try another approach to the problem--that kind of
property manipulation is hairy. That said, you could do something like

(not tested, since it's a bad idea to do it this way anyway)

var currObj:Object = obj; // object that you want to apply this chain to
var propArray:Array = apps.split('.');
propArray.forEach(function(item:*, index:int, array:Array):void {
    currObj = currObj[item];
});

trace(currObj.name); // should be the name as in your example

Again, this is a bad idea--you should consider another approach that
doesn't involve this kind of reference. It's usually hard to debug, hard
to follow when reading the code, and prone to subtle errors (e.g., if
you rename one of the components but neglect to change the String).

-- 
Maciek Sakrejda
Truviso, Inc.
http://www.truviso.com

-----Original Message-----
From: flexawesome <[EMAIL PROTECTED]>
Reply-To: flexcoders@yahoogroups.com
To: flexcoders@yahoogroups.com
Subject: [flexcoders] Re: Converting String to hiberarchy path ?
Date: Fri, 11 Jul 2008 02:15:59 -0000

hhuumm....I have tried that...it didn't work

Error Msg

ReferenceError: Error #1069: Property myPanel.myButton not found on 
testapp and there is no default value.

--- In flexcoders@yahoogroups.com, Sherif Abdou <[EMAIL PROTECTED]> wrote:
>
> I think you can do this[apps].name; 
> 
> 
> 
> ----- Original Message ----
> From: flexawesome <[EMAIL PROTECTED]>
> To: flexcoders@yahoogroups.com
> Sent: Thursday, July 10, 2008 8:45:03 PM
> Subject: [flexcoders] Converting String to hiberarchy path ?
> 
> 
> I was curious if I am able to convert a String to hiberarchy path
> 
> for example: I am able to retrieve the button info. by 
> myPanel.myButton. name
> 
> what about I have a String: var apps:String = "myPanel.myButton" , 
is 
> it possible to convert the String back to REAL hiberarchy path that 
> allows me to use => myPanel.myButton. name?
> 
> Cheers
> 
> ==== sample application code ====
> 
> <mx:Panel id="myPanel" >
> <mx:Button id="myButton" />
> </mx:Panel>
>




 


Reply via email to