[AS2] Class Parameters and eval ()
:confused::confused::confused::confused::confused: What is happening here? Cuz I hav noooo clue, and been trying to figure it out for hours:scared:
Flash Version 8.0.0
Code:
class Tile {
public var walkable:Boolean;
public var frame:Number
static var tile0, tile1, tileF:Object;
public function Tile (id:Number) {
var tile:Object = tileClass ("tile1");
walkable = tile.walkable;
frame = tile.frame;
trace(tile) //outputs undefined
}
static function tileClass (str:String) {
tile0 = {walkable:true, frame:1}
tile1 = {walkable:false, frame:2}
tileF = {walkable:false, frame:20}
trace (eval(str)); //outputs undefined
trace (str); // outputs tile1
trace(str==="tile1");// outputs true
trace (eval("tile1")); // outputs [object][object]
return eval(str);
}
}
Feel free to copy and paste this and try it out, Thanks for any help I can get!