Skip to main content
Inspiring
April 29, 2014
Question

String to new Function

  • April 29, 2014
  • 1 reply
  • 479 views

Hello,

Is it possible to convert a string to a new function e.g.

var myNewFunction:Function;

myNewFunction = "myStringFunction(){trace('this has been called');};"

myNewFunction();

//trace Result

this has been called

Thanks in advance

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
April 29, 2014

not in general.

DazFazAuthor
Inspiring
April 29, 2014

Hi kglad,

When you say "not in general", do you mean it is possible?

Thanks

kglad
Community Expert
Community Expert
April 29, 2014

no.

you have to parse the string (using the flash string/array methods) and then recreate the function.