Xml 函数名并调用此函数
我有函数和xml文件,其中存储了函数和组件的名称Xml 函数名并调用此函数,xml,apache-flex,actionscript-3,mxml,Xml,Apache Flex,Actionscript 3,Mxml,我有函数和xml文件,其中存储了函数和组件的名称 <commands> <command> <flexObject>myObject1</flexObject> <flexFunction>myFunction1</flexFunction> </command> <command> <flexObject>myObject2</flexObje
<commands>
<command>
<flexObject>myObject1</flexObject>
<flexFunction>myFunction1</flexFunction>
</command>
<command>
<flexObject>myObject2</flexObject>
<flexFunction>myFunction2</flexFunction>
</command>
</commands>
调用myObject1.myFunction1函数
MyObject和myFunctions是经典组件及其函数
当我调用setCommandsService.send
in handler是这个函数的字符串名称,我不知道如何将它作为函数添加到数组中。试试:
this[arr[0]]();
或
您可能需要使用getDefinitionByName
import flash.utils.getDefinitionByName;
var function:Function = getDefinitionByName('namespace.myFunction1') as Function;
这只适用于名称空间级别的函数,但不适用于静态类方法。好的,您需要确保这些对象和函数都存在,但应该可以使用actionscript的动态特性:
var functions:Array = [];
for(var i:uint = 0, len:uint = xml.command.length(); i<len; i++)
{
if(this[xml.command[i].flexObject] && this[xml.command[i].flexObject][xml.command[i].flexFunction])
{
functions.push(this[xml.command[i].flexObject][xml.command[i].flexFunction]);
}
}
var函数:数组=[];
对于(var i:uint=0,len:uint=xml.command.length();i
import flash.utils.getDefinitionByName;
var function:Function = getDefinitionByName('namespace.myFunction1') as Function;
var functions:Array = [];
for(var i:uint = 0, len:uint = xml.command.length(); i<len; i++)
{
if(this[xml.command[i].flexObject] && this[xml.command[i].flexObject][xml.command[i].flexFunction])
{
functions.push(this[xml.command[i].flexObject][xml.command[i].flexFunction]);
}
}