views:

266

answers:

1

I have a Flash in AS3. I want to dynamically load code that performs some kind of calculations. Is it doable with AS3 (I've read that there is no eval)? Should I use an interpreter in AS3 that gets the data and does the calculations?

My first thought was to load an external swf that does all the calculations but I think having an engine that gets input from a socket is more elegant as a solution.

So, how is it possible to execute algorithms that come from a server in a swf file?

+2  A: 

Well, there is an AS3 Eval Library by metalbot. You should probably take a look.

Also you may use browser JS engine to perform JavaScript eval with code downloaded from server. Look at ExternalInterface AS3 class for that.

If number of your code snippets is limited you could use special swfs (prepared beforehand) with those code snippets, downloaded from server. After loading an swf you can use it's codebase without any evals.

dragonfly