Re: [flexcoders] Function from string?
- Nov 6, 2013 Expand MessagesView SourceBoth Array and Object support  property access.
Regarding converting a String to a Function: AS is compiled, not
interpreted, so only strings that have been compiled into functions can be
run. You can fill an object or array full of functions and choose one at
runtime, but that is not the same as constructing a string at runtime and
trying to run it. Eval() will do that in JS, but there is no AS
Some options are:
1) There are some AS3 eval() functions in third-party libraries. But they
are unlikely to be fast.
2) You can send the string to a server, compile it into a SWF and load
that SWF and run it.
3) If the function doesn't require much information from the rest of the
app, you could write the string to JS and call eval on it via
On 11/6/13 2:02 PM, "A. P. Damien" <APDamien@...> wrote:
>On 11/6/2013 9:16 AM, Keith Reinfeld wrote:
>> Perhaps the following syntax will help:
>> var func:String = ³yourFunctionName²;
>Thanks. I hadn't fully assimilated the fact that an object can also be
>treated as an array. Do I have to declare the class 'dynamic' for this
>trick to work? Or is it always legal to do this from inside the class?
>Flexcoders Mailing List
>Alternative FAQ location:
>http://www.mail-archive.com/flexcoders%40yahoogroups.comYahoo Groups Links