Either declare the val variable outside of the function or add a parameter. Something like this:
public function defaultResult(event:ResultEvent):void { var result:Object = event.result; var val = result.DATARESULTS.STATE; state_select(val); } public function state_select(val : String) -TH --- In flexcoders@yahoogroups.com, "Jason B" <[EMAIL PROTECTED]> wrote: > > im not sure what the best way to do this? > > > > <?xml version="1.0" encoding="utf-8"?> > <mx:Module xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" > width="650" height="350" > creationComplete="stations_placeofbusiness.send();"> > <mx:Script> > <![CDATA[ > import mx.managers.PopUpManager; > import mx.rpc.events.ResultEvent; > import mx.rpc.events.FaultEvent; > import mx.controls.Alert; > public function closeModule():void { > PopUpManager.removePopUp(this); > } > > public function defaultResult(event:ResultEvent):void > { > var result:Object = event.result; > var val = > {stations_placeofbusiness.lastResult.DATARESULTS.STATE}; > if(result.errorCode > 0) > Alert.show(result.errorText); > > } > > public function state_select(){ > > //var val = > "{stations_placeofbusiness.lastResult.DATARESULTS.STATE}"; > > > for (var i: int = 0; i < state.dataProvider.length; i++) { > if ( val == state.dataProvider[i].label) { > state.selectedIndex = i; > > > > break; > } > } > > } > > ]]> > </mx:Script> > <!-- LEO WILL DO THESE LATER > <mx:HTTPService id="officialcity_dataprovider" > url="/managementconsole.php/stationsinfo/stations_selectbox?FIELDNAME=??\ ?" > method="POST" showBusyCursor="true" result="defaultResult(event)" > requestTimeout="30" /> > <mx:HTTPService id="reason_dataprovider" > url="/managementconsole.php/stationsinfo/stations_selectbox?FIELDNAME=??\ ?" > method="POST" showBusyCursor="true" result="defaultResult(event)" > requestTimeout="30" /> > --> > > <mx:HTTPService id="stations_placeofbusiness" > url="/managementconsole.php/stationsinfo/stations_placeofbusiness" > method="POST" showBusyCursor="true" result="defaultResult(event)" > requestTimeout="30" > > <mx:request xmlns=""> > <station_id> > {station_id.text} > </station_id> > </mx:request> > </mx:HTTPService> > > > <!-- this is used to save place of business data entry !--> > <mx:HTTPService id="stations_placeofbusiness_save" > url="/managementconsole.php/stationsinfo/Stations_placeofbusiness_savere\ sults" > method="POST" showBusyCursor="true" result="defaultResult(event)" > requestTimeout="30" > > <mx:request xmlns=""> > <station_id> > {station_id.text} > </station_id> > > <street_addr> > {address.text} > </street_addr> > <city> > {city.text} > </city> > <state> > {state.text} > </state> > <zip5> > {zip5.text} > </zip5> > <zip4> > {zip4.text} > </zip4> > <contact_phone> > {phone.text} > </contact_phone> > <contact_fax> > {fax.text} > </contact_fax> > <contact_email> > {email.text} > </contact_email> > > <contact_person> > {contact_person.text} > </contact_person> > > <payerinfo> > {checknumber.text} > </payerinfo> > > <payername> > {payername.text} > </payername> > <amount> > {amount.text} > </amount> > <reason> > {reason.text} > </reason> > > <comments> > {comments.text} > </comments> > <record_update_ts> > {record_update_ts.text} > </record_update_ts> > > <station_addr_skey> > {station_addr_skey.text} > </station_addr_skey> > > </mx:request> > </mx:HTTPService> > > <mx:XMLList id="statesXMLList"> > <state abbrev="AL" name="Alabama" /> > <state abbrev="AK" name="Alaska" /> > <state abbrev="AZ" name="Arizona" /> > <state abbrev="AR" name="Arkansas" /> > <state abbrev="CA" name="California" /> > <state abbrev="CO" name="Colorado" /> > <state abbrev="CT" name="Connecticut" /> > <state abbrev="DE" name="Delaware" /> > <state abbrev="DC" name="Dist of Columbia" /> > <state abbrev="FL" name="Florida" /> > <state abbrev="GA" name="Georgia" /> > <state abbrev="HI" name="Hawaii" /> > <state abbrev="ID" name="Idaho" /> > <state abbrev="IL" name="Illinois" /> > <state abbrev="IN" name="Indiana" /> > <state abbrev="IA" name="Iowa" /> > <state abbrev="KS" name="Kansas" /> > <state abbrev="KY" name="Kentucky" /> > <state abbrev="LA" name="Louisiana" /> > <state abbrev="ME" name="Maine" /> > <state abbrev="MD" name="Maryland" /> > <state abbrev="MA" name="Massachusetts" /> > <state abbrev="MI" name="Michigan" /> > <state abbrev="MN" name="Minnesota" /> > <state abbrev="MS" name="Mississippi" /> > <state abbrev="MO" name="Missouri" /> > <state abbrev="MT" name="Montana" /> > <state abbrev="NE" name="Nebraska" /> > <state abbrev="NV" name="Nevada" /> > <state abbrev="NH" name="New Hampshire" /> > <state abbrev="NJ" name="New Jersey" /> > <state abbrev="NM" name="New Mexico" /> > <state abbrev="NY" name="New York" /> > <state abbrev="NC" name="North Carolina" /> > <state abbrev="ND" name="North Dakota" /> > <state abbrev="OH" name="Ohio" /> > <state abbrev="OK" name="Oklahoma" /> > <state abbrev="OR" name="Oregon" /> > <state abbrev="PA" name="Pennsylvania" /> > <state abbrev="RI" name="Rhode Island" /> > <state abbrev="SC" name="South Carolina" /> > <state abbrev="SD" name="South Dakota" /> > <state abbrev="TN" name="Tennessee" /> > <state abbrev="TX" name="Texas" /> > <state abbrev="UT" name="Utah" /> > <state abbrev="VT" name="Vermont" /> > <state abbrev="VA" name="Virginia" /> > <state abbrev="WA" name="Washington" /> > <state abbrev="WV" name="West Virginia" /> > <state abbrev="WI" name="Wisconsin" /> > <state abbrev="WY" name="Wyoming" /> > > </mx:XMLList> > > > > <mx:Panel x="0" y="0" width="650" height="347" layout="absolute" > title="Change Place of Business"> > <mx:Label x="3" y="3" id="station_id" > text="{parentApplication.stationinfo_station_id.text}" width="84" > visible="false"/> > <mx:Label x="3" y="3" id="station_addr_skey" > text="{stations_placeofbusiness.lastResult.DATARESULTS.STATION_ADDR_SKEY\ }" > width="84" visible="false"/> > <mx:Label x="3" y="3" id="record_update_ts" > text="{stations_placeofbusiness.lastResult.DATARESULTS.RECORD_UPDATE_TS}\ " > width="84" visible="false"/> > <mx:Label x="3" y="3" id="addr_code" > text="{stations_placeofbusiness.lastResult.DATARESULTS.ADDR_CODE}" > width="84" visible="false"/> > > > <mx:Label x="10" y="10" text="Address" width="84"/> > <mx:Label x="10" y="38" text="City" width="84"/> > <mx:Label x="10" y="64" text="State" width="84"/> > <mx:Label x="10" y="115" text="Zip" width="84"/> > <mx:Label x="10" y="141" text="Phone" width="84"/> > <mx:Label x="10" y="169" text="Fax" width="84"/> > <mx:TextInput x="102" y="167" id="fax" > text="{stations_placeofbusiness.lastResult.DATARESULTS.CONTACT_FAX}"/> > <mx:Label x="10" y="197" text="Email" width="84" /> > <mx:TextInput x="102" y="195" id="email" > text="{stations_placeofbusiness.lastResult.DATARESULTS.CONTACT_EMAIL}"/> > <mx:TextInput x="102" y="8" id="address" > text="{stations_placeofbusiness.lastResult.DATARESULTS.STREET_ADDR}"/> > <mx:TextInput x="102" y="36" id="city" > text="{stations_placeofbusiness.lastResult.DATARESULTS.CITY}"/> > <mx:ComboBox x="102" y="62" id="state" labelField="@name" > dataProvider="{statesXMLList}" creationComplete="state_select();"/> > <mx:TextInput x="102" y="113" width="69" id="zip5" > text="{stations_placeofbusiness.lastResult.DATARESULTS.ZIP5}"/> > <mx:TextInput x="193" y="113" width="69" id="zip4" > text="{stations_placeofbusiness.lastResult.DATARESULTS.ZIP4}"/> > <mx:TextInput x="102" y="139" id="phone" > text="{stations_placeofbusiness.lastResult.DATARESULTS.CONTACT_PHONE}"/> > > <mx:Label x="10" y="223" text="Contact Person" width="84"/> > <mx:TextInput x="102" y="223" id="contact_person" > text="{stations_placeofbusiness.lastResult.DATARESULTS.CONTACT_PERSON}"/\ > > > <mx:Button x="237" y="255" label="Save" > click="stations_placeofbusiness_save.send(); "/> > <mx:Button x="359" y="255" label="Cancel" click="closeModule()"/> > <mx:Label x="179" y="115" text="-"/> > <mx:Label x="10" y="90" text="Offical City"/> > <mx:ComboBox x="102" y="88" id="officalcity"></mx:ComboBox> > <mx:TextArea x="406.5" y="10" height="19" wordWrap="false" > editable="true" enabled="true" id="checknumber" /> > <mx:TextArea x="406.5" y="37" height="19" wordWrap="false" > editable="true" enabled="true" id="payername" text="Barry's Auto Parts"/> > <mx:TextArea x="406.5" y="63" height="19" wordWrap="false" > editable="true" enabled="true" id="amount" text="50.00"/> > <mx:Label x="304" y="10" text="Payment Info" width="94.5"/> > <mx:Label x="304" y="37" text="Payer" width="74"/> > <mx:Label x="304" y="63" text="Amount" width="74"/> > <mx:Label x="304" y="89" text="Reason" width="74"/> > <mx:TextArea x="406" y="126" width="198" editable="true" > enabled="true" wordWrap="true" id="comments" /> > <mx:Label x="304" y="141" text="Comments" width="75" enabled="true"/> > <mx:ComboBox x="406.5" y="87" width="160" id="reason"></mx:ComboBox> > > <mx:Label x="245" y="268" > text="{stations_placeofbusiness_save.lastResult.SUCCESS}"> > > </mx:Label> > </mx:Panel> > > </mx:Module> >