Dynamically Referencing Variables and Methods in ActionScript
Submitted by on
Sometimes, the state of an object decides which method has to be executed. Instead of an unwieldy switch
construction like this …
case "sleep":
sleep();
break;
case "walk":
walk();
break;
}
… you can use the someObject[someExpression]
notation. This works for any object, and you can use it to access both variables and methods. All those lines from above become this:
English