Reputation: 1117
I haven't used AS2 before and I have to fix someones code which was written in AS2 and is using flash. Here is the AS2 code:
var evalOpt = eval("option"+optObj);
var evalPlace = eval("_root.placed"+plcObj);
trace(evalOpt);
trace(evalPlace);
set("ans"+plcObj, evalOpt);
I traced both evalOpt and evalPlace. evalOpt is
<b>0</b>
and evalPlace is
_level0.placed6
. What does the set() function do in AS2? I looked through the rest of his code and did not find the set() function anywhere.
Note: I have opened it in Flash and on the top it says "AS1 / AS2".. I don't know if this is AS1 or AS2, but I am assuming it is AS2.
Upvotes: 0
Views: 344
Reputation: 999
In AS2 set()
function does the assignment. First parameter is variable name as String
, second parameter is the value you want to assign.
Important thing to note about first parameter, is that if you have a variable say:
var color:String = "orange";
and you call
set(color, "blue"); // will *not* work as intended
then variable color
will not be set to "blue", instead new variable named "orange"
will be created and value "blue" assigned to it.
set("color", "blue"); // will work as intended
In your example function set()
assigns whatever data is in variable evalOpt
to variable name that evaluates from "ans"+plcObj
Upvotes: 1