Flash eval ( ) vs. Array operator

What’s the difference between eval ( ) and Array operator [ ” ” ]? According to this article Scope Chain and Memory waste in Flash MX,

eval can resolve a path:

var val = eval ( “obj.prop.prop.prop.prop” )

the Array operator can only retrieve an immediate property of an object:

var val = obj [ “prop” ]

eval can even resolve to class methods:

var obj = {numbers: {a:.1, b:.4 } };

var num = eval ( “obj.numbers.a” ) + obj.numbers [ “b” ];

var roundedNum = eval ( “Math.round” ) ( num );

trace( num ); // traces .5
trace( roundedNum ); // traces 1

»     » del.icio.us     » Digg It!

Tags: , , , , , ,

2 Comments »

  1. jgraup said,

    February 22, 2007 @ 10:45 am

    Eval() on the left side of an argument causes error
    http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_16187

    Although this code was allowed in Macromedia Flash 5, it actually deviates from the ECMA-262 standard. Macromedia Flash MX is now fully ECMA-262 complaint and no longer allows this structure when authoring a Macromedia Flash Player 6 SWF.

  2. Wood fired boilers. said,

    February 3, 2010 @ 3:13 am

    Boilers….

    European boilers. Residential boilers. Copper boilers. Weil mclain boilers costs. Corn boilers. Raypak boilers….

RSS feed for comments on this post · TrackBack URI

Leave a Comment

You must be logged in to post a comment.

best kansas city bookstore pirodr! 666