简体   繁体   中英

Send to c# Array Objects from Flex

I need to send to c# an array of objects from Flex. Anybody know how can I do this?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM