Actually, eval() in AS has never been a full eval like in Javascript.  I
has only been able to evaluate a reference to an object.

The direct replacement(was in AS2 as well) is "bracket notation", which
is actually more powerful than eval, because it can be used on the left
side of an assignment as well as on the right.

If befor you had:
var oMyObject:Obect = eval("myString" + myVar);

Change it to:
var oMyObject:Object = this["myString" + myVar].

Tracy

-----Original Message-----
From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of {reduxdj}
Sent: Saturday, December 09, 2006 4:05 PM
To: [email protected]
Subject: Re: [flexcoders] eval() function removed in AS 3.0 ??


from an earlier post about this topic:

You need to roll it on your own. You could split the given path into
its parts and try to evaluate one piece after the other until you come
to the end.

public function eval( scope : Object, path : String ) : Object
{
       if( path == null ) return null;

       var result : Object = scope;
       var parts : Array = path.split('.');
       while( result != null && parts.length > 0 )
       {
             var part : String = parts.shift();
             result = result[ part ];
       }
       return result;
}

Untested code, but hopefully you get the point. Maybe you need to add
some exception handling, when you try to access non existing
properties.

Cheers,

Ralf,











pdflibpilot wrote:
>
> According to the documentation "eval()" has been removed as function -
> is there an alternative ? I really would like to use this function.
>
>  




--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives:
http://www.mail-archive.com/flexcoders%40yahoogroups.com 
Yahoo! Groups Links





Reply via email to