views:

1119

answers:

8

I have some basic experience in making Flex sites, but I think I have more use for Flex in making a desktop AIR application.

Anyway, I was wondering if it is at least possible to use C# alongside Actionscript/AIR? I can't find any example of this.

Also, can I use custom Flash components in a Flex app? I know I can use Javascript components.

Thanks

+5  A: 

Your options with AIR are limited to HTML/JS, Flash/ActionScript or Flex. There's no support for other languages and frameworks.

John Sheehan
I see. Wouldn't this limit my choice of available 3rd party APIs to use? Also, Actionscript can't send email but it can call methods in other languages (I think). Also, wouldn't this mean my apps will be fairly basic?
dotnetdev
dotnetdev, you can call a server to send/receive data from an air application.
Tracker1
A: 

The whole point of AIR is to enable web developers who know AS/JS to be able to easily make desktop applications which are automatically portable to win, linux, and mac. Hence why there is no way to connect it to other languages like C#, C++, etc, since web developers generally don't care about those languages, and if they were used, the app is no longer portable (yes, most languages can be ported to other OS's with some effort, but the point of AIR is that you write whatever you want, and it runs everywhere with no extra work).

If you want to combine C# and Flash, instead of trying to put C# inside AIR, what you should be doing is putting Flash inside a C# app. There are various resources for this on the internets, here is one I found in a quick search: Example: Using the External API with an ActiveX container. When you are searching, make sure it talks about the newer, more advanced ExternalInterface / External API method, and not the oldschool SetVariable/CallFunction/watch method. The newer one is much easier to use & has more features.

davr
A: 

Also, yes, you can use custom Flash components inside a Flex app. Generally you just make a SWC inside Flash CS3 (or CS4), and then import that SWC inside Flex Builder (or Flex SDK, or FlashDevelop, or ...)

If you are making the components yourself inside Flash CS3, you should use the Flex Component Kit. It provides some features for you, and puts in the boilerplate code, to make your flash component play nice inside Flex. It's included with Flex Builder/Flex SDK.

davr
A: 

If by 'alongside' you mean using c# as middleware to connect to your database (probably SQL Server), or to perform remote calculations then yes you can. You can connect to a c# service using remote objects. The midnight coders produce a product called WebORB that is fairly simple to use. Version 3.4 was a totally free version that should suffice if you are building desktop applications in Air. The next two versions are not free but basically offer no real advantage to you.

slukse
+1  A: 

Slukse is correct -- it depends on what you mean by "alongside."

Obviously you can't compile C# code into a SWF -- that much we know. But you can certainly embed (as davr suggests) an ActiveX control into a .NET Forms app, load the SWF into that control, and use the ExternalInterface API to bridge the C# code running in the desktop app and the ActionScript code running in the SWF. If by alongside you mean writing server-side C# code to render data consumable by the Flex app, then of course, you can do that, too -- there's plenty of documentation out there covering how to connect a Flash or Flex (or AIR, by extension) app to Web Services of a variety of flavors, including the relatively new-ish WCF stuff.

Another way to go would be to run a standalone C# desktop app (e.g., a service, console app or the like) and have that app listening over a certain local port -- then have your SWF talk to that app using the Socket classes. I'm doing something like this now (with Java, not C#, but the idea's the same) for a personal project.

Christian Nunciato
A: 

The only way I know of doing this is with C# web service programs and the AIR/Flex apps communicate with the web services.

Mike Wills
A: 

Try merapi :) they have branched it into C# recently

Mikelangelo