flex 类型转换

type conversion if flex

我正在使用 Flerry 作为我的 Flex 桌面应用程序的 Java-Flex 桥。

如何将 Java 中的 List 转换为 Flex 中的 ArrayCollection

弹性代码:-

[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 代码:-

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

可以转换哪些数据类型以及如何转换?

您尝试将数据类型 mx.collections:IList 转换为 UI 组件类型 spark.components:List,这当然会导致异常。 尝试按照错误消息提示使用 mx.collections:IList:

  screenList.addAll(event.result as IList);