Calling a function inside AS from fx:component flex

PirateSmack

New Member
This one is probably really simple, but I can't find online an answer. Heres what I have:\[code\]<fx:Script> <![CDATA[ protected function DestIsAirport(event:MouseEvent):void { navigator.pushView(AirportSelector); } protected function DestIsAddress(event:MouseEvent):void { navigator.pushView(DestinationInfoView); } ]]></fx:Script>\[/code\]and then I have a pop up container just below that and it looks like this:\[code\]<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>\[/code\]I want the two buttons to run different functions from the AS3 script. This produces an error:1180: Call to a possibly undefined method DestIsAddress.1180: Call to a possibly undefined method DestIsAirport.How do I get those buttons to run those two functions? Entire source file:\[code\]<?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="http://stackoverflow.com/questions/11039437/Abbott Park"></fx:Object> <fx:Object data="http://stackoverflow.com/questions/11039437/Addison"></fx:Object> <fx:Object data="http://stackoverflow.com/questions/11039437/Algonquin"></fx:Object> <fx:Object data="http://stackoverflow.com/questions/11039437/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>\[/code\]
 
Back
Top