我正在尝试使用Adobe Flash Builder 4.6在MobileFlex项目中使用FlexLib。出于学习原因,我正在尝试创建ScheduleViewer1_Sample.mxml的iPad版本。
出于一些神秘的原因 - 至少是我不理解的原因 - 它不适用于最新的flexlib(2.6-M2)。
使用以前的版本(2.5 - googlecode上的最新版本),我只需要更改使用的命名空间,它就像一个魅力。
例如我改变了
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
xmlns:flexlib="http://code.google.com/p/flexlib/"
creationComplete="onCreationComplete();">
<mx:Script>
<![CDATA[
//Stuff that just worked
]]>
</mx:Script>
<flexlib:ScheduleViewer id="scheduleViewer"
width="600" height="400"
dataProvider="{ dataProvider }"
startDate="{ startDate }" endDate="{ endDate }" />
</mx:Application>
到
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark" title="MySchedule"
xmlns:flexlib="http://code.google.com/p/flexlib/"
creationComplete="onCreationComplete()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
//I didn't change anything at the scripting part
]]>
</fx:Script>
<flexlib:ScheduleViewer id="scheduleViewer"
width="600" height="400"
dataProvider="{ dataProvider }"
startDate="{ startDate }" endDate="{ endDate }" />
</s:View>
这很有用。我不知道这样做是否正确,但它有效。使用GitHub的最新版本,它不再起作用了。我总是收到错误说
'ScheduleViewer'声明必须包含在标记内,因为它不能分配给默认属性的类型'Array'或元素类型'mx.core.IVisualElement'。
如何让FlexLib中的组件在iPad-Project中运行?
更新:我机器上已编译的FlexLib,现在错误已更改为
无法将
<flexlib:ScheduleViewer>
解析为组件实现。
答案 0 :(得分:2)
大多数FlexLib组件都是在Flex 4中引入的spark架构之前的。我不希望它们针对移动设备进行优化,因此您可能会遇到问题。
Flex 4中也引入了IVisualElement接口,看起来您尝试使用的组件没有实现它。
我建议您尝试获取组件的源代码,并在当前版本的Flex中重新编译它。只要组件扩展UIComponent,你应该没问题,因为UIComponent实现了IVisualElement。如果您的组件没有扩展UIComponent,那么您将必须实现可能需要更改组件的IVisualElement。