2 Replies Latest reply on Sep 15, 2009 12:43 PM by development_is_fun

    CSHARP and AIR


      Hello World!


      I have built a csharp/flex application which is really cool!  I really need csharp to connect to another system but that is a whole other story(just know that i must have csharp)....



      Initially I built the csharp project with a flash control inside of a window, then I built the flex side project as a flash (web application).  csharp and flash talk and play nice using fscommand.  Dude Sweet!


      Then I wanted to drag stuff (i.e. pictures, documents, and etc) into my flex application.  ... So i then converted my flash project into AIR, built my drag and drop, and all was cool.  But when I build, I get a .swf and a executable.  The generated exe file runs fine and i can see everything.  But I cant take the swf and put it into my csharp flash control anymore.


      I get these errors:

      VerifyError: Error #1014: Class flash.events::NativeWindowBoundsEvent could not be found.

      ReferenceError: Error #1065: Variable _macCloseButtonStyle__embed_css_mac_close_up_png_502016742 is not defined.

      ReferenceError: Error #1065: Variable _AdvancedDataGridStyle__embed_css_Assets_swf_TreeNodeIcon_1149873145 is not defined.

      ReferenceError: Error #1065: Variable WindowMinimizeButtonSkin_macMinDownSkin is not defined.

      ReferenceError: Error #1065: Variable _winMinButtonStyle__embed_css_win_min_dis_png_1242201614 is not defined.
      ReferenceError: Error #1065: Variable _DragManagerStyle__embed_css_Assets_swf_mx_skins_cursor_DragCopy_2096733126 is not defined.
      I'm guessing that the executable has extra AIR libraries that flash it did not have before....So, how can I connect AIR with my csharp?

        • 1. Re: CSHARP and AIR
          adobe_paul Adobe Employee

          To embed a SWF in a .NET application as you've been doing, you're using the Flash Player ActiveX control hosted in your application.


          There is no AIR equivalent to the Flash Player ActiveX control, and (as you guessed) the AIR-only apis are not available in Flash Player.


          AIR is designed for creating standalone applications, not user interfaces hosted in other applications. Some people create AIR applications that communicate with other non-AIR code (such as Java or .NET code) but in that case the application is architected somewhat differently. Instead of it being a .NET application that includes a Flash Player (or AIR) control, the whole thing runs as two separate applications -- the AIR application that provides the user interface and probably as much functionality as possible, with the Java/.NET application running in the background (in a way that's usually described as a "server" or "service"). Communication between them can happen in various ways, but most commonly the server app runs a socket server and the AIR app communicates to the server app using the Socket class.


          One approach for doing this with .NET is Mike Chambers' CommandProxy project:

          http://www.mikechambers.com/blog/2008/01/17/commandproxy-net-air-integration-proof-of-conc ept/


          For Java there's the Merapi project, which has been in development longer and is more polished -- but of course you've made it clear that you need C# =)


          Unfortunately this architecture complicates things somewhat because it means you have to have a way to install both apps together, and run both apps together. I believe the typical approach is to have the executable that the user actually runs be the server part, and have it load the AIR app as soon as it's executed. (Or alternatively, to have a third bootstrapper application that is the one the user runs, that loads both the server and the AIR UI app.)


          Since the early days of AIR one of the most vocal feature requests has been the ability to call native code or other processes from within an AIR app., and you can rest assured that this will be implemented some day. But as things stand in the current version of AIR, the approach I described above is how other developers implement this kind of application.



          As a complete side note, if you are using the Flash Player ActiveX control in a .NET app, you can use the ExternalInterface class rather than fscommand. The documentation includes a sample app demonstrating using the ExternalInterface class to embed a SWF UI in a C# app.

          1 person found this helpful
          • 2. Re: CSHARP and AIR
            development_is_fun Level 1

            Well I guess what I was afraid is true.  But no problem.


            My thought is to have a blended UI.  I will have flex fill an entire window except charp drag-drop-container that is docked at the bottom of the window.