这个可能很简单,但我在网上找不到答案。这是我所拥有的:
<fx:Script>
<![CDATA[
protected function DestIsAirport(event:MouseEvent):void {
navigator.pushView(AirportSelector);
}
protected function DestIsAddress(event:MouseEvent):void {
navigator.pushView(DestinationInfoView);
}
]]>
</fx:Script>
然后我在它下面有一个弹出容器,它看起来像这样:
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<fx:Component className="DestAlert">
<s:SkinnablePopUpContainer x="50" y="200">
<s:TitleWindow title="Destination">
<s:VGroup horizontalAlign="center" verticalAlign="middle" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%">
<s:Label text="Is your destination an airport?"/>
</s:VGroup>
<s:HGroup horizontalAlign="center" verticalAlign="middle" paddingTop="40" paddingBottom="8" gap="5" width="100%">
<s:Button label="Yes" bottom="10" left="10" width="100" fontSize="16" click="DestIsAirport(event)"/>
<s:Button label="No" bottom="10" right="10" width="100" fontSize="16" click="DestIsAddress(event)"/>
</s:HGroup>
</s:TitleWindow>
</s:SkinnablePopUpContainer>
</fx:Component>
</fx:Declarations>
我希望这两个按钮从 AS3 脚本运行不同的功能。这会产生错误:1180:调用可能未定义的方法 DestIsAddress。1180:调用可能未定义的方法 DestIsAirport。
如何让这些按钮运行这两个功能?
整个源文件:
<?xml version="1.0" encoding="utf-8"?>
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="Enter Pick Up Address">
<fx:Script>
<![CDATA[
protected function button1_clickHandler(event:MouseEvent):void
{
navigator.popView();
}
protected function DestIsAirport(event:MouseEvent):void {
navigator.pushView(AirportSelector);
}
protected function DestIsAddress(event:MouseEvent):void {
navigator.pushView(DestinationInfoView);
}
]]>
</fx:Script>
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
<fx:Component className="DestAlert">
<s:SkinnablePopUpContainer x="50" y="200">
<s:TitleWindow title="Destination">
<s:VGroup horizontalAlign="center" verticalAlign="middle" paddingTop="8" paddingBottom="8" paddingLeft="8" paddingRight="8" gap="5" width="100%">
<s:Label text="Is your destination an airport?"/>
</s:VGroup>
<s:HGroup horizontalAlign="center" verticalAlign="middle" paddingTop="40" paddingBottom="8" gap="5" width="100%">
<s:Button label="Yes" bottom="10" left="10" width="100" fontSize="16" click="close()"/>
<s:Button label="No" bottom="10" right="10" width="100" fontSize="16" click="close()"/>
</s:HGroup>
</s:TitleWindow>
</s:SkinnablePopUpContainer>
</fx:Component>
</fx:Declarations>
<s:actionContent>
<s:Button label="Back" click="button1_clickHandler(event)"/>
</s:actionContent>
<s:TextInput top="6" horizontalCenter="-1" prompt="Address Line 1"/>
<s:TextInput top="47" horizontalCenter="-1" prompt="Address Line 2"/>
<s:RadioButton top="90" label="IL - Illinois" horizontalCenter="-94"/>
<s:RadioButton top="90" label="WI - Wisconsin" horizontalCenter="72"/>
<s:SpinnerListContainer bottom="60" width="320" height="211" horizontalCenter="0">
<s:SpinnerList width="317" height="100%" labelField="data" selectedIndex="0">
<s:ArrayList>
<fx:Object data=""></fx:Object>
<fx:Object data="Abbott Park"></fx:Object>
<fx:Object data="Addison"></fx:Object>
<fx:Object data="Algonquin"></fx:Object>
<fx:Object data="Alsip"></fx:Object>
</s:ArrayList>
</s:SpinnerList>
</s:SpinnerListContainer>
<s:Button bottom="10" width="302" label="Next" click="(new DestAlert()).open(this, false)"
fontSize="24" horizontalCenter="0"/>
</s:View>