How to access Function from one script to another script in same mxml

ぃ、小莉子 提交于 2019-12-25 05:15:47

问题


this is one script in my.mxml

  <fx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        public function __changeSel():void{

        }
    ]]>
  </fx:Script>

another script in component tag in same my.mxml

<fx:Component>
                                        <s:ComboBox change="changeSel(event)">  
                                            <s:id>selID</s:id>
                                            <s:dataProvider>
                                                    <s:ArrayCollection>
                                                        <fx:String>Less Than</fx:String>
                                                    </s:ArrayCollection>                                                    
                                            </s:dataProvider>
                                            <fx:Script>
                                                <![CDATA[
                                                    public function changeSel(even:Event):void{
                                                         __changeSel();
                                                    }
                                                ]]>
                                            </fx:Script>
                                        </s:ComboBox>
                                    </fx:Component>             

But when i call __changeSel(); it dose not recognize this function. is there any way to get this thing fixed.


回答1:


You should not use inline components. That leads to a scope shift. Write a proper self contains component and dispatch events over the display list, so the composites root can set a listener on the bubbling events.

Otherwise try to use outerDocument in the inline renderer to invoke the method.



来源:https://stackoverflow.com/questions/10910030/how-to-access-function-from-one-script-to-another-script-in-same-mxml

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!