如何从一个脚本访问功能在同一个MXML另一个脚本 [英] How to access Function from one script to another script in same mxml

查看:115
本文介绍了如何从一个脚本访问功能在同一个MXML另一个脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是my.mxml一个脚本,

this is one script in my.mxml

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

        }
    ]]>
  </fx:Script>

在成分标签在同一my.mxml另一个脚本

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>             

但是,当我打电话__changeSel();它的剂量不能识别这个功能。有没有什么办法让这件事情解决。

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

推荐答案

您不应该使用内联组件。这导致一个范围的转变。写一个适当的自我包含在显示列表组件和调度事件,使复合材料的根可以在冒泡的事件设置监听器。

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.

否则,尝试使用在添加outerDocument内联渲染器调用的方法。

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

这篇关于如何从一个脚本访问功能在同一个MXML另一个脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆