package com.fourD.core { import flash.utils.getQualifiedClassName; public class MethodCaller { public function call(instance:*, method:String, args:*):* { var returnValue:*; var parameters:Array = args as Array; trace("METHOD CALLER\n" + instance); trace("instance = " + flash.utils.getQualifiedClassName(instance)); trace("method = " + method); if(!instance) { } else if(!method) { } else if(!instance.hasOwnProperty(method)) { } else if(!(instance[method] is Function)) { } else { try { if(!parameters) { returnValue = instance[method](); } else { returnValue = (instance[method] as Function).apply(instance, parameters); } } catch(error:ArgumentError) { } catch(error:TypeError) { } } return returnValue; } } }