Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/actionscript-3/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Actionscript 3 如何基于AS3 flash中的其他组合框动态更改组合框值_Actionscript 3_Combobox - Fatal编程技术网

Actionscript 3 如何基于AS3 flash中的其他组合框动态更改组合框值

Actionscript 3 如何基于AS3 flash中的其他组合框动态更改组合框值,actionscript-3,combobox,Actionscript 3,Combobox,我有一个如下所示的xml文件 <tree> <branch1><node1/><node2/><node3/><branch1> <brach2><node1/><node2/><node3/><branch1> <branch3><node1/><node2/><node3/><branch1> <

我有一个如下所示的xml文件

<tree>
<branch1><node1/><node2/><node3/><branch1>
<brach2><node1/><node2/><node3/><branch1>
<branch3><node1/><node2/><node3/><branch1>
<branch4><node1/><node2/><node3/><branch1>
</tree>
现在我希望当选择分支1时,combobox2应该自动加载

node1
node2
node3
我现在的代码是

for each(var element:XML in testXML.elements()) {
                    comboFar.addItem({label:element.name(),label:element.name()});

                }

您应该为combobox1分配一个事件处理程序,如:

    var myXML:XML= <tree>
                       <branch name='1'><node name='1'/><node name='2'/><node name='3'/></branch>
                       <branch name='2' ><node name='1'/><node name='2'/><node name='3'/></branch>
                       <branch name='3'><node name='1'/><node name='2'/><node name='3'/></branch>
                   </tree> // or something like this



    combobox1.addEventListener(Event.CHANGE,changeListener); 


    function changeListener(e:Event):void
    {
         populateCombobox2(myXML.branch.(@name == e.currentTarget.selectedItem.@name));
    }

    function populateCombobox2(combo2Data:XML):void
    {
        combobox2.dataSource = combo2Data;
        combobox2.displayName = "@name"; // I don't remember if this is correct, and I can't 
                                         //check it now, but this is the logic.... if its not 
                                         //correct tell me, and when I get home I can tell you 
                                         //the correct way
    }
    var myXML:XML= <tree>
                       <branch name='1'><node name='1'/><node name='2'/><node name='3'/></branch>
                       <branch name='2' ><node name='1'/><node name='2'/><node name='3'/></branch>
                       <branch name='3'><node name='1'/><node name='2'/><node name='3'/></branch>
                   </tree> // or something like this



    combobox1.addEventListener(Event.CHANGE,changeListener); 


    function changeListener(e:Event):void
    {
         populateCombobox2(myXML.branch.(@name == e.currentTarget.selectedItem.@name));
    }

    function populateCombobox2(combo2Data:XML):void
    {
        combobox2.dataSource = combo2Data;
        combobox2.displayName = "@name"; // I don't remember if this is correct, and I can't 
                                         //check it now, but this is the logic.... if its not 
                                         //correct tell me, and when I get home I can tell you 
                                         //the correct way
    }