Go Back   CodingForums.com > :: Client side development > Flash & ActionScript

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 02-22-2005, 10:57 AM   PM User | #1
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
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)
firepages is offline   Reply With Quote
Old 02-22-2005, 11:34 AM   PM User | #2
liorean
The thread killer


 
Join Date: Feb 2003
Location: Umeå, Sweden
Posts: 5,575
Thanks: 0
Thanked 84 Times in 75 Posts
liorean will become famous soon enoughliorean will become famous soon enough
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.
__________________
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

Last edited by liorean; 02-22-2005 at 02:14 PM..
liorean is offline   Reply With Quote
Old 02-22-2005, 02:13 PM   PM User | #3
firepages
Super Moderator


 
Join Date: May 2002
Location: Perth Australia
Posts: 3,890
Thanks: 5
Thanked 79 Times in 78 Posts
firepages will become famous soon enough
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)
firepages is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:33 AM.


Advertisement
Log in to turn off these ads.