dcsimg
A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: [disc] strings to actionscript

  1. #1
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853

    [disc] strings to actionscript

    I wonder, is there a way to 'render' a string like it is normal actionscript. Something like:

    var as = "attachMovie('mc','mc',9)"

    .. and then somehow 'run' the code in the string.

    I'm afraid this is not possible, but I still ask, cause you'll never know

  2. #2
    Ihoss
    Guest
    eval("attachMovie('mc','mc',9)");

  3. #3
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    sure its possible,check this one out,its an "interpreter" (you can type actionscript into a textfield and it executes it right away),it has a few limitations but you can still do most common things with it
    go to
    http://www.flashcomponents.net/
    then type interpreter in the search field,press the search button and download or preview interpreter component set 1.3
    (sorry,would place the direct url but its always changing on that site..)

  4. #4
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853
    That's funny. A friend just told me about eval(), but he used it for another purpose (in a way like _root["t"+i]). But thanx for the help. I will use it for sure!

  5. #5
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    no probs,eval comes in handy at times and for something like a runtime "interpreter" its quite cool but i wouldn´t use it in other cases if i don´t have to (it can tend to be cpu intensive)
    Last edited by tomsamson; 05-25-2004 at 04:51 PM.

  6. #6
    Senior Member
    Join Date
    Jul 2003
    Location
    Melbourne, Australia
    Posts
    189
    I was considering using this concept as a way of protecting actionscript from decompilation.

    1) Have .swf connect to my database, and retrieve a string.
    2) Eval the string into actionscript.

    But then I realised that someone could probably just write something to read the variable being returned from the database

    Anyone know any ways around this?

  7. #7
    Yes we can tomsamson's Avatar
    Join Date
    Sep 2001
    Location
    Team Titan Secret Lair
    Posts
    4,666
    it could be done in several ways but i have to say using such an interpreter for games or apps is no good idea.
    you can´t use everything which actionscript has to offer and its also slower than normal scripts

  8. #8
    Senior Member jbum's Avatar
    Join Date
    Feb 2004
    Location
    Los Angeles
    Posts
    2,920
    I'm pretty sure IHoss's eval example is incorrect.

    The actionscript eval works as Baukereg says, to convert strings to identifiers. but it doesn't accept free-formatted actionscript.

    I have a pet theory: there is no interpreted language slow enough that someone isn't going to try to implement an even slower interpreted language with it.
    Last edited by jbum; 05-26-2004 at 05:06 AM.

  9. #9
    Lunatic Baukereg's Avatar
    Join Date
    Nov 2000
    Location
    Lowlands
    Posts
    853
    This doesn't work though:

    code:

    action = "_root.attachMovie('blok','blok',9)";
    eval(action);


  10. #10
    Senior Member webgeek's Avatar
    Join Date
    Sep 2000
    Posts
    1,356
    Actionscript's eval() is NOT the same as JavaScript's eval(). In JavaScript, you can dynamically execute anything with eval(). It can create scoped variables and execute functions, etc. In Flash, it's hit and miss. The Flash documentation calls this distinction out as well.

    Jobe and I have played with having server-side logic generate ActionScript code that Flash dynamically executes. As soon as we ran into eval()'s shortcomings, we decided to drop the idea.

    An interpreter would be another option but Tomsamson is right, it will be slow.

    Have fun!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center