PDA

View Full Version : Run(str:String) method


nprzybylo
02-13-2007, 09:56 PM
Hello,

I am looking for an ActionScript function that reads in a string of actionscript and runs it. For instance, if the statement

Run("i=i+10;");

was placed in the middle of a function, it will take the defined variable i and add 10 to it. Please let me know if there is anything that is already built in to the ActionScript library that would allow me to do this.

Thanks!

senocular
02-13-2007, 10:47 PM
Nothing built into the library that can do that. Someone made something that does a pretty good job for most AS2 strings, but I haven't heard of anything for AS3.

Daedalus
02-14-2007, 11:23 AM
I was reading one of the blogs of a adobe flash system developer and they said they did not include the jave type of eval() function (which is what your looking for) because it would make the player download size too big and something about that fact that flex uses a java compiler not a native AS compiler.

http://www.kaourantin.net/2006/11/spidermonkeys-relative-tamarin-joins.html

This open source tamarin project looks good, pity its only a partial implementation.
http://www.mozilla.org/projects/tamarin/faq.html#opensource

You could always evaluate a string and then execute a certain bit of code depending on what the contents of the string is but you would still have to write all the possible combinations of code you would want to execute before you compile the swf.