问题
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