Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts

    flash5:: eval() fails in swf , works in fla ?

    Hi , weirdness , I have a flash object , during it lifetime it has to use eval()

    //variables already loaded e.g count_1 - count_7 exist and can be traced
    // 'x' exists and can be traced
    _root.num_ims = eval('count_'+x);

    if x = 5 and count_5 = 10 then _root.num_ims should equal 10 and indeed it does when testing (in flash) as expected , but when using in the output swf in the browser the eval() call is failing , everything else works just fine.

    and its driving me potty ~

    any one seen this behaviour before ?
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    Well, never having worked with ActionScript I can't say anything final, but I know that the compact ECMAScript specification allows dropping of eval and the like for speed when embedding the language.

    I suggest you replace the variables count_1 through count_7 with an array count instead, and use array notation count[x] instead of eval('count_'+x). Additionally, array lookup is many times faster than eval, so that might even speed the execution up.
    Last edited by liorean; 02-22-2005 at 03:14 PM.
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Super Moderator
    Join Date
    May 2002
    Location
    Perth Australia
    Posts
    4,108
    Thanks
    11
    Thanked 101 Times in 99 Posts
    Hey Liorean , that worked a treat , the variables come via GET so I can't get directly at the array , but simply loading the loaded variables into an array indeed did the job

    I swear I have used eval in flash-web-applications before , however since your suggestion works I am keeping quiet so cheers !
    resistance is...

    MVC is the current buzz in web application architectures. It comes from event-driven desktop application design and doesn't fit into web application design very well. But luckily nobody really knows what MVC means, so we can call our presentation layer separation mechanism MVC and move on. (Rasmus Lerdorf)


  •  

    Posting Permissions

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