How can I share code between C # and Flex?

I am developing a Flex / Flash application that accesses an ASP.Net/C# server. Is there any way to share the code between them?

The server provides a rather interesting domain model, which the client is intended for maniuplate. Ideally, I would like to be able to define this domain model once and use it for consistency on both sides. I am after all the benefits that come with DRY.

I'm new to Flex, but I had in mind some intermediate language that compiles for both C # and ActionScript.

Update

I currently have a basic REST-style web service that sends XML-serialized versions of objects over the wire to Flex. This works great, but I'm really interested in sharing simple business logic that combines with these objects. There are certain business rules that need to be processed both on the server and on the client, and perhaps I would rather not return to the server for performance reasons.

+4
source share
7 answers

I ran into this problem, so I wrote a C # to ActionScript converter.

http://cs2as.codeplex.com/

Write your logic in C # and add this utility as a post build step. Then your business logic will be available in both environments. It works very well for me - I use it to exchange over 30,000 lines of code.

+4
source

I would crack the domain model specification and create it in both languages. But this is probably not the most effective thing.

+1
source

Check out http://www.fluorinefx.com/ (this is an open source remote launch). I used it to call web services written in C # from ActionScript, and it works great. Once it’s nice that your C # can return a DataSet (or something similar), and the Flourine environment will convert it to an object that ActionScript understands.

0
source

Update

You can pass objects using lists, but what you are really looking at is just data.

You cannot pass a "method" to a client.

  • They do not have to respect him. Once they own the data, you cannot control whether they adhere to the methods you went through or not.
  • You would not want to trust what they sent to you afterwards.

I think the problem is with the setup.

You can handle whatever you want on the client side with ActionScript, and you just need to put the business logic that you want to manipulate on the ActionScript side if you want to do this on the client side.

answer olde

I use Flex and C # together using a web service layer .

You might want to take a look at creating web services to have a flexible conversation with your C # code.

0
source

Not that I know, C # is a strongly typed, compiled language, but ActionScript is a freely typed, interpreted language. Chalk and cheese, I'm afraid.

0
source

What if you serialize objects in XML and send them to Flex .... which, at least, will allow you to exchange data

0
source

All Articles