Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Instead of...
- var someVariable:String = "string 3";
- switch (someVariable)
- {
- case "string1":
- /** code **/
- break;
- case "string2":
- /** code **/
- break;
- case "string3":
- /** code **/
- break;
- case "string4":
- /** code **/
- break;
- case "string5":
- /** code **/
- break;
- }
- // Do this:
- _methodMapForSomeVariable = new Dictionary();
- _methodMapForSomeVariable["string1"] = _doSomething;
- _methodMapForSomeVariable["string2"] = _doSomethingElse;
- _methodMapForSomeVariable["string3"] = _doSomething;
- _methodMapForSomeVariable["string4"] = _doSomethingElse;
- _methodMapForSomeVariable["string5"] = _doSomething;
- _methodMapForSomeVariable[someVariable]();
- private function _doSomething():void
- {
- // code...
- }
- private function _doSomethingElse():void
- {
- // code...
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement