我也没玩过flex,学习学习,呵呵.

解决方案 »

  1.   

    明白楼主的意思可惜我不会flex,你用xml形式返回串是否简单些,要么就再找找相关的结构定义。
      

  2.   

    我猜想是map hashmap 
    我想跨语言只能用map来描述如下的这种结构。
    map的key是属性value是值
    子节点又是list
    和javascript的json格式一样似乎
    private var companyData:ArrayCollection = new ArrayCollection(
    [ {type:"department", title:"Finance", children:new ArrayCollection(
                                                             [ {type:"employee", name:"John H"},
                                                               {type:"employee", name:"Sam K"} ] ) },
       {type:"department", title:"Engineering", children: new ArrayCollection(
                                                           [ {type:"employee", name:"Erin M"},
                                                             {type:"employee", name:"Ann B"} ] ) },
       {type:"department", title:"Operations", children: new ArrayCollection()}
    ] );以上答案纯属猜想
      

  3.   

    private var companyData:ArrayCollection = new ArrayCollection(
    [ {type:"department", title:"Finance", children:new ArrayCollection(
                                                             [ {type:"employee", name:"John H"},
                                                               {type:"employee", name:"Sam K"} ] ) },
       {type:"department", title:"Engineering", children: new ArrayCollection(
                                                           [ {type:"employee", name:"Erin M"},
                                                             {type:"employee", name:"Ann B"} ] ) },
       {type:"department", title:"Operations", children: new ArrayCollection()}
    ] );
      

  4.   

    sunyujia:你说的这个意思没错,确实需要转换成这样的格式,但是静态的去定义没有问题,问题就在我的数据是动态的,也就是从后来取的,那么我在mxml中new ArrayCollection()的时候怎么去写呢?
      

  5.   

    java中的ArrayList到flex的ArrayCollection是自动的
    我所以我的猜想java代码如下
       ArrayList al = new ArrayList(); 
        for(int o=0;i <5;i++){
            Map map=new HashMap();
            map.put("type","typetest");
            map.put("name","nametest");
            al.add(map); 
        } 
        return al; 
      

  6.   

    为自己的猜想找到点证据http://zhidao.baidu.com/question/65043211.html
    注意这句话
    FLEX里没有MAP类,但只要你知道了JAVA里MAP的KEY,那么FLEX里就可以作为OBJECT的一个属性来访问。
      

  7.   

    楼主的意思有一点明白!~!
    但是flex这个东西还没有接触过~!
    关于树的问题用JavaScript和JSON做过!~!
    呵呵~!期待有高手来给你解决这个问题!~!
    顶了!~!
      

  8.   

    显示定义类型为<String> 呢?
      

  9.   

    在WebContent/WEB-INF/FLEX
      在remoting-config.xml中增加一个数据源  <destination id="myService">
         <properties>
              <source>DBMySQLService</source>  --java数据源
         </properties>
      </destination>
    然后在MXML文件中加入:
    <mx:RemoteObject id="GetUsers" destination="myService"/>希望能帮到你
      

  10.   

    补充下:
    DBMySQLService  是java环境编写的类名,
    然后用GetUsers.getTreeData()得到返回的纪录
      

  11.   

    给你看个简单的例子:
    1.从java中一类
    public class userInfo { private int ID;
    private String name;
    private String sex;
    private int age;
    private String password;
            ...
            ...
    get/set方法
    }
      
    2.增加一个session bean.类名DBMySQLService.public userInfo[] getUsers() {
        return userdataset;
    }
    3.在WebContent/WEB-INF/FLEX
      在remoting-config.xml中增加一个数据源  <destination id="myService">
         <properties>
              <source>DBMySQLService</source>  --java数据源
         </properties>
      </destination>
    4.在Flex_01.mxml中加入一个
      <mx:RemoteObject id="GetUsers" destination="myService"/>   private function initApp():void
       {
    GetUsers.getUsers.addEventListener(ResultEvent.RESULT,OKHandleEvent);
    GetUsers.getUsers(); //getUsers()为java反馈函数
       } 增加一个DataGrid组件 id = dgb
      
      private function OKHandleEvent(evt:ResultEvent):void{
         dgs.dataProvider = ArrayUtil.toArray(evt.result); 
      }
      

  12.   

    感谢你sunyujia的回答,你的代码给了我不少启示,我准备测试一下,因为flex对于java端返回的map类型可以通过key来获取value对应的值,那么我在java端应该可以将arraylist对应到map中去。
      

  13.   

    你的意思是将arraylist显示定义为string??
    public ArrayList<String> aaa(){}这样吗???
    好像是有点意思?不过如果是一个树形结构的话,我不知道这样的显示定义能返回什么结构?xml的树形结构?
      

  14.   

    arrayList   跟   mxml  的  arraycollection  是对应的
    你需要些一个   as的 class  对应·