I need to send to c# a array of objects from Flex. Anybody know how do I do this?
Sorry for my English, I am Brazilian. Thank´s
Sidnei Cachate.
I need to send to c# a array of objects from Flex. Anybody know how do I do this?
Sorry for my English, I am Brazilian. Thank´s
Sidnei Cachate.
This is how you can pass parameters to your .net application
<?xml version="1.0"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml">
<mx:Script>
<![CDATA[
public function callService():void {
// Cancel all previous pending calls.
myService.cancel();
var params:Object = new Object();
params.param1 = 'val1';
params.param2 = 'val2';
myService.send(params);
}
]]>
</mx:Script>
<mx:HTTPService
id="myService"
url="http://localhost/myCsharpProject/getService.aspx"/>
<mx:Button click="callService();" label="send"/>
</mx:Application>
Depending on your needs, you might want to check out something like WebORB for .NET.
The idea is that you can use middleware to translate between Actionscript objects on the client and .NET objects on the server.
The provided answers (Shua and Mike S) might both be useful, but have you considered something like using JSON or XML formats for the API? Serialize your objects into a text format and tranfer those to your application via HTTP protocols, and then deserialize on the client into ActionScript objects. I'm assuming that you have a C# server and a Flex client. If you create a generic API (like JSON) you can switch clients whenever you like so you're not bound to Flex, or HTML.
If for some reason you're saying C#, but the data is already in the browser, you can try using the ExternalInterface methods in Flash to communicate between browser Javascript and your Flex Application. If you need some examples of this, just ask.