1
votes

I am using Flerry as Java-Flex bridge for my Flex Desktop Application.

How to convert List in Java to ArrayCollection in Flex

Flex Code:-

[Bindable]public var screenList:ArrayCollection;
<flerry:NativeObject id="windowControllerObj" source="ls.window.EnumAllWindowNames"
  singleton="true" fault="windowControllerObj_faultHandler(event)">
    <flerry:NativeMethod id="getWindowNames" name="getAllWindowNames" 
      result="windowControllerObj_resultHandler(event)"
      fault="getWindowNames_faultHandler(event)"/>
</flerry:NativeObject>

protected function windowControllerObj_resultHandler(event:ResultEvent):void
    {
        Alert.show("success");
        screenList.addAll(event.result as List);
        Alert.show(screenList.toString());
    }

Java Code:-

public List<String> getAllWindowNames() {
   return List<String>;
}

1067: Implicit coercion of a value of type spark.components:List to an unrelated type mx.collections:IList. LSFinal.mxml /LSFinal/src line 2289 Flex Problem

What datatypes can be converted and How?

1

1 Answers

1
votes

You try to cast data type mx.collections:IList to UI component type spark.components:List, which of course leads to exception. Try to follow the error message hint and use mx.collections:IList:

  screenList.addAll(event.result as IList);