2 Replies Latest reply on Dec 30, 2009 2:22 PM by miguel8312

    POP-UP datagrid pass values to Main application

    miguel8312 Level 3

      I have two simple applications and i cant seem to get this to work i found a work around but is rather anoying.

      my first app does a call to a web service and retrieves info.

      main app looks like this

       

       

       

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

      <mx:Application

       

       

      xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" cornerRadius="7" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#432A2A, #E96F6F]" height="700">

      <mx:Style

       

       

      source="b.css"/>

       

      <mx:Script>

      <![CDATA[

       

       

      import mx.managers.PopUpManager;

       

      import mx.containers.TitleWindow;

       

      import flash.geom.Point;

       

      private var point1:Point = new Point();

       

      private function showWindow():void {

       

      var win : WEBSERVICE2 = new WEBSERVICE2();

      PopUpManager.addPopUp(win,

      this,true);

      PopUpManager.centerPopUp(win);

      win.Query2=adrss;

       

      trace(win.Query2);

       

       

      }

      ]]>

       

      </mx:Script>

      <mx:Form

       

      width="680" horizontalCenter="0" height="610" y="10">

       

       

      <mx:TitleWindow width="632" height="518" layout="absolute" horizontalCenter="0" horizontalAlign="center" verticalAlign="middle" showCloseButton="false" id="p_window" cornerRadius="10" title="Direct Pay">

       

      <textInput borderStyle="inset" themeColor="#0F0FF4" cornerRadius="7" id="adrss" borderColor="#0A0B0B" editable="false" enabled="true" x="85" y="37"/>

       

       

      </mx:TitleWindow>

       

       

      </mx:Form>

       

      </mx:Application>

       

       

      --------------pretty simple

       

      then the pop up window looks like this.

       

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

      <!--<mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" backgroundGradientAlphas="[1.0, 1.0]" height="188" backgroundGradientColors="[#432A2A, #432A2A]">

      <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" width="1220" height="365" cornerRadius="7" backgroundGradientAlphas="[1.0, 1.0]" backgroundGradientColors="[#432A2A, #E96F6F]">-->

       

        

       

      <mx:TitleWindow xmlns:mx="http://www.adobe.com/2006/mxml"

      layout="

      vertical" width="1220" height="376"

      title="

      Vendor Query" horizontalAlign="center"

      showCloseButton="

      false">

       

        

        

        

      <!-- this is a comment i believe if i add creationComplete="initApp()" to the

      mx tag above then the function will start as soon as the application runs.-->

       

      <mx:Script>

      <![CDATA[

       

      import mx.managers.PopUpManager;

       

      import mx.controls.Text;

       

       

      // A reference to the TextInput control in which to put the result.

       

      // public var adrss:Text;

       

       

      // Event handler for the OK button.

       

      private function returnName():void {

       

      // loginName.text="Name entered: " + userName.text;

      PopUpManager.removePopUp(

      this);

      }

      ]]>

       

      </mx:Script>

       

        

        

        

        

        

        

        

        

      <mx:Script>

      <![CDATA[

       

      import mx.controls.Alert;

       

      import mx.rpc.events.FaultEvent;

       

      import mx.rpc.events.ResultEvent;

       

      import mx.controls.Text;

       

       

      public function initApp():void {

       

      // Get Data from WebService and fill datagrid when you fist invoke the application

       

      trace("hello11111");

       

      //Getcheckdata(ws);

      ws.GetVendor(Query.text);

       

      }

       

       

      private function GetVendor(event:ResultEvent):void {

       

      // Databind data from webservice to datagrid

       

      //ws.SaveEmployee(Query.text)

      datagrid.dataProvider = event.result;

       

      //chk.text= event.result.toString();

       

      //Alert.show(event.toString())

       

      //chk.text=ws.HelloWorld.toString

       

      trace("hello");

      }

       

      private function fault(event:FaultEvent):void {

       

      // Oppps some error occured

      Alert.show(event.toString());

       

      trace("hello");

      }

       

       

      private function AddRecord(event:MouseEvent):void {

       

      // Save a record using a WebService method

       

      //ws.SaveEmployee(txtEmpId.text, txtEmpName.text, txtEmpEmail.text); //

      }

       

       

       

      ]]>

      </mx:Script>

       

       

       

      <mx:Script>

      <![CDATA[

       

      import mx.events.ListEvent;

       

      import mx.controls.Text;

       

      public var myArray:Array;

       

      // A reference to the TextInput control

       

      // in which to put the result.

       

      public var adrss2:Text;

      [

      Bindable]

       

      public var spriden_last_name:String;

       

      public var targetComponent:TextInput;

       

       

      private function list( e:ListEvent ):void {

      spriden_last_name =e.currentTarget.selectedItem.spriden_last_name;

      Query2.text=e.currentTarget.selectedItem.spriden_last_name;

       

      //adrss2=e.currentTarget.selectedItem.spriden_last_name;

      PopUpManager.removePopUp(

      this);

      }

      ]]>

      </mx:Script>

       

       

       

       

        

      <mx:WebService

       

      id="ws" wsdl="http://localhost:1571/WebSite6/Service.asmx?WSDL" fault="fault(event)">

       

      <mx:operation

      name="

      GetVendor"

      resultFormat="

      object"

      result="GetVendor(event)"

      />

       

      </mx:WebService>

       

        

        

        

      <mx:DataGrid

       

      id="datagrid" width="1200" height="75%" borderColor="#913E48" themeColor="#A81E38" alternatingItemColors="[#943F3F, #B46969]" fontFamily="Arial" fontSize="12" borderStyle="none" alpha="0.99" textAlign="center"

      color="

      #131617" itemClick="list( event );" >

       

      <mx:columns>

       

      <mx:DataGridColumn headerText="Vendor Name" dataField="spriden_last_name"/>

       

      <mx:DataGridColumn headerText="state" dataField="spraddr_stat_code"/>

       

      </mx:columns>

       

       

       

      </mx:DataGrid>

       

      <mx:HBox width="558" height="35">

       

      <mx:Button label="Cancel" click="PopUpManager.removePopUp(this);"/>

       

      <mx:Button label="Button" click="initApp()" enabled="true"/>

       

      <mx:TextInput id="Query" height="26"/>

       

      <mx:TextInput id="Query2" height="26" visible="False"/>

       

      </mx:HBox>

       

      <!--<mx:TextInput id="chk"/>-->

       

        

       

      </mx:TitleWindow>

       

       

       

       

       

       

      the only way i seem to be able to make this work is by putting an invisible input box win.Query2=adrss; and set the reference to that on the parent APP but this just does not seem right I mean there is got to be a much easier way to do this. can anyone please lend a hand plus i rather not put boxes that im not going to use on my APP.

       

      Thanks

      Miguel