Groups | Blog | Home
all groups > flash actionscript > march 2004 >

flash actionscript : "eval" a script, return a value (not a var ref)?


ntsiii
3/29/2004 10:01:44 PM
I need to run a script within an object and return the result of that script.

I really want stock JavaScript functionality, like
var script = "iWidth * iLength"; //these are variables in the scope of the
eval call
//or could be object
properties.
var iArea = eval(script );

ActionScript's eval will only give me a variable reference, or undefined.

Any ideas?

TIA
Tracy
Jeckyl
3/30/2004 10:21:04 AM
Not possible unless you write your own expression interpreter in script.

Bet more to the point is WHY do you need to do this. Unless the expression
is completely dynamic (eg something user types in on your site), then you
rarely if ever need to eval and expression. There are better ways to do it.

AddThis Social Bookmark Button