5 Replies Latest reply on Jul 11, 2007 10:41 AM by Jihaes

    Embedding Flex App with C# windows application?

    Jihaes
      Is there a way to use Flex as a source of UI and have it talk back and forth with a C# web application that can run a query and send back data? (I know that .Net can generate XML to talk back to Flex application but how can I talk back and forth?

      (Retrieve user inputs from Flex form and save the data into a database using C# application?)
      Any links to examples would help.
      Thanks
        • 1. Re: Embedding Flex App with C# windows application?
          ntsiii Level 3
          HTTPService to the rescue. It does not matter what is producing the xml on the server, as long as it is xml strings. I use vb.net.

          Here are some code snippets to get you started. There are also full examples on cflex.net.

          Tracy
          Sample code using HTTPService, e4x, handler function to populate a list item.
          Also shows usage of AsyncToken.

          The DataGrid tag:
          <mx:DataGrid id="dg" dataProvider="{_xlcMyListData}" .../>


          The HTTPService tag:
          <mx:HTTPService id="service" resultFormat="e4x" result="onResult(event)" fault="..../>

          Script block declaration:
          import mx.rpc.Events.ResultEvent;
          [Bindable]private var _xlcMyListData:XMLListCollection;

          Invoke send:
          var oRequest:Object = new Object();
          oRequest.Arg1 = "value1";
          var callToken:AsyncToken = service.send(oRequest);
          token.callId = "myQuery1";

          Result Handler function:
          private function onResult(oEvent:ResultEvent):void {
          var xmlResult:XML = XML(event.result); //converts result Object to XML. can also use "as" operator
          var xlMyListData:XMLList = xmlResult.myListData; //depends on xml format, is row data
          _xlcMyListData = new XMLListCollection(xlMyListData); //wrap the XMLList in a collection
          trace(_xlcMyListData.toXMLString()); //so you can see exactly how to specify dataField or build labelFunction
          var callToken:AsyncToken = oEvent.token;
          var sCallId = callToken.callId; //"myQuery1"
          switch(sCallId) {
          case "myQuery1":
          doQuery2();
          break;
          ...
          }
          }//onResult
          • 2. Re: Embedding Flex App with C# windows application?
            Jihaes Level 1
            hey thanks for the respond.
            I have another question regarding passing data between a flex application that is embedded in a windows form. If I import the .swf file using the Shockwave Flash Object from the windows form, is there a way to pass data back and forth without using a webservice? Or is webservice the only means of communication?
            • 3. Re: Embedding Flex App with C# windows application?
              ctzn99 Level 1
              If I recal correctly the flash object can only pass data back and forth to the web browser so if you're embedding the flash ocx into a windows form there isn't anyway for them to talk to each other.

              For what it sound like you're trying to do have considered AIR? It will allow you to build desktop flex applications. You don't have as much control over the desktop as you would with a .net application but for most business applications i suspect it will be more than useful. It will let you build non square windows, access the file system, etc. And you can use a mixture of html / javascript / ajax / flex / and web services to build what you want (without it looking like a web page).

              http://labs.adobe.com/technologies/air/

              I know i've got one client that i'm developing an applciation for and it's perfect.

              Regards,
              Zach
              • 4. Re: Embedding Flex App with C# windows application?
                ntsiii Level 3
                You can communicate between the flex app and the browser using ExternalInterface. Would that help?
                Tracy
                • 5. Re: Embedding Flex App with C# windows application?
                  Jihaes Level 1
                  Thanks guys.
                  I'll do some research on AIR and ExternalInterface