0
votes

the question is, how?

An AS3 ordered object is supposed to keep the properties insertion order, so i pass the Ordered Object through a spark remote object and receive it as a LinkedHashMap, but the for each loop reads em in a messed up order.

I also tried to find documentation about passing OrededObjects in my free time for the last 3 days without any luck so far =/

Im not pursuing the functionality in general, i just wanna know if this is possible.

short example:

Flex

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Declarations>    
        <s:RemoteObject
            id="exampleRO"
            destination="example"/>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import mx.utils.OrderedObject;
            private var oobject:OrderedObject=new OrderedObject();
            private function sendObject(){
                oobject["key1"]="value1";
                oobject["key2"]="value2";
                oobject["key3"]="value3";
                oobject["key4"]="value4";
                exampleRO.send(oobject);
            }
        ]]>
    </fx:Script>
    <s:Button click="sendObject()"/>
</s:Application>

Java backend

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

import org.apache.log4j.Logger;

public class somename{
    private static Logger logger = Logger.getLogger(somename.class);
    public void send(LinkedHashMap<String, Object> oobject){
        Iterator it;
        Map.Entry e;
        for(it=oobject.entrySet().iterator(); it.hasNext();){
            e = (Map.Entry)it.next();
            logger.info("oobject key: "+  e.getKey() + " value:" + e.getValue());
        }

    }
}
1

1 Answers

0
votes

just got it working =)

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx">
    <fx:Declarations>    
        <s:RemoteObject
            id="exampleRO"
            destination="example"/>
    </fx:Declarations>
    <fx:Script>
        <![CDATA[
            import org.as3commons.collections.LinkedMap;
            private var oobject:LinkedMap=new LinkedMap();
            private function sendObject(){
                oobject.add("key1","value1");
                oobject.add("key2","value2");
                oobject.add("key3","value3");
                oobject.add("key4","value4");
                oobject.add("key5","value5");
            }
        ]]>
    </fx:Script>
    <s:Button click="sendObject()"/>
</s:Application>