this["your_function_name"]();
请看例子:
private function playTrack(location:String):void {
var dot_position:Number = location.lastIndexOf('.');
var file_ext:String = location.substr(dot_position+1);
var play_function_name:String = file_ext+"_player";
if (this.hasOwnProperty(play_function_name)) {
this[play_function_name]();
}else {
Alert.show("Do not support this file extension("+file_ext+").");
}
}
参考:http://livedocs.adobe.com/flex/3/html/help.html?content=ProgrammingHTMLAndJavaScript_03.html
No comments:
Post a Comment