0 Replies Latest reply on Oct 25, 2011 5:37 AM by mauprice

    base URL as string variable


      I'm trying to get to grips with Flash Builder 4.5 and have been struggling with this problem for a week now, if anyone has some suggestions I would really appreciate it.



      I have been looking for a way to pass a string variable to HTTPMultiService for the baseURL path.


      I want to pass the test.text field contents to the HTTPMultiService for the baseURL to be the base path but i just get an error.


      Is there a way to pass a variable to the base url to be used as the base path?




      My code is as follows.


      <?xml version="1.0" encoding="utf-8"?>

      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"






                                       minWidth="955" minHeight="600"





                                    import mx.controls.Alert;

                                    import mx.events.FlexEvent;

                                    import mx.rpc.events.ResultEvent;


                                    import services.testing.mypath;


                                    import spark.events.TextOperationEvent;


                                    protected function mypath_resultHandler(event:ResultEvent):void


                                              OperationResult.token = testing.Operation();








                          <s:CallResponder id="OperationResult"/>


              <s:HTTPService id="mypath" url="mypath.xml" resultFormat="e4x" result="mypath_resultHandler(event)"/>


                          <testing:Testing id="testing"

                                                                   fault="Alert.show(event.fault.faultString + '\n' + event.fault.faultDetail)"




                          <!-- Place non-visual elements (e.g., services, value objects) here -->


                <s:TextArea id="test" x="34" y="264" width="487" height="33"

                                              text="{mypath.lastResult}"/> <<<< This is the variable i want to use which contains the path i wish to use in the class below.

                <s:DataGrid id="mydg" x="50" y="58" requestedRowCount="4">



                                              <s:GridColumn dataField="office" headerText="office"></s:GridColumn>

                                              <s:GridColumn dataField="departmentid" headerText="departmentid"></s:GridColumn>

                                              <s:GridColumn dataField="street" headerText="street"></s:GridColumn>

                                              <s:GridColumn dataField="zipcode" headerText="zipcode"></s:GridColumn>

                                              <s:GridColumn dataField="state" headerText="state"></s:GridColumn>

                                              <s:GridColumn dataField="lastname" headerText="lastname"></s:GridColumn>

                                              <s:GridColumn dataField="firstname" headerText="firstname"></s:GridColumn>

                                              <s:GridColumn dataField="photofile" headerText="photofile"></s:GridColumn>

                                              <s:GridColumn dataField="city" headerText="city"></s:GridColumn>

                                              <s:GridColumn dataField="id" headerText="id"></s:GridColumn>

                                              <s:GridColumn dataField="title" headerText="title"></s:GridColumn>

                                              <s:GridColumn dataField="officephone" headerText="officephone"></s:GridColumn>

                                              <s:GridColumn dataField="email" headerText="email"></s:GridColumn>

                                              <s:GridColumn dataField="cellphone" headerText="cellphone"></s:GridColumn>




                                    <fx:Object id="id1" cellphone="cellphone1" city="city1" departmentid="departmentid1"

                                                           email="email1" firstname="firstname1" lastname="lastname1" office="office1"

                                                           officephone="officephone1" photofile="photofile1" state="state1"

                                                           street="street1" title="title1" zipcode="zipcode1"></fx:Object>


                          <s:AsyncListView list="{OperationResult.lastResult}"/>





      Super_Testing.as Class



      * This is a generated class and is not intended for modification.  To customize behavior

      * of this service wrapper you may modify the generated sub-class of this class - Testing.as.


      package services.testing


      import com.adobe.fiber.core.model_internal;

      import com.adobe.fiber.services.wrapper.HTTPServiceWrapper;

      import mx.rpc.AbstractOperation;

      import mx.rpc.AsyncToken;

      import mx.rpc.http.HTTPMultiService;

      import mx.rpc.http.Operation;

      import valueObjects.Mydata;



      import com.adobe.serializers.json.JSONSerializationFilter;




      internal class _Super_Testing extends com.adobe.fiber.services.wrapper.HTTPServiceWrapper


          private static var serializer0:JSONSerializationFilter = new JSONSerializationFilter();



          // Constructor

          public function _Super_Testing()


              // initialize service control

              _serviceControl = new mx.rpc.http.HTTPMultiService("http://server/mytest/");   <<< I want to replace this hard coded baseURL with a variable from the text field test.text.

               var operations:Array = new Array();                                                                    the text field is loaded first before the datagrid is triggered but this still gives an error

               var operation:mx.rpc.http.Operation;                                                                     if I put the variable in place of the hard coded url string.

               var argsArray:Array;                                                                                          Any suggestions would be very welcome.



               operation = new mx.rpc.http.Operation(null, "Operation");

               operation.url = "mytest.php";

               operation.method = "GET";

               operation.serializationFilter = serializer0;

               operation.resultElementType = valueObjects.Mydata;




               _serviceControl.operationList = operations; 









          //init initialization routine here, child class to override

          protected function preInitializeService():void








            * This method is a generated wrapper used to call the 'Operation' operation. It returns an mx.rpc.AsyncToken whose

            * result property will be populated with the result of the operation when the server response is received.

            * To use this result from MXML code, define a CallResponder component and assign its token property to this method's return value.

            * You can then bind to CallResponder.lastResult or listen for the CallResponder.result or fault events.


            * @see mx.rpc.AsyncToken

            * @see mx.rpc.CallResponder


            * @return an mx.rpc.AsyncToken whose result property will be populated with the result of the operation when the server response is received.


          public function Operation() : mx.rpc.AsyncToken


              var _internal_operation:mx.rpc.AbstractOperation = _serviceControl.getOperation("Operation");

                          var _internal_token:mx.rpc.AsyncToken = _internal_operation.send() ;

              return _internal_token;