我在 Flash Builder 4.5 中为 android 和 iOS 制作一个移动应用程序,并使用 itemRenderer 和 iconitemrenderer 类为我的应用程序制作一个选项列表。出于某种原因,我无法让它们可点击,或者定义每个被点击时要执行的操作。基本上,我的目标是使用 FB 的“视图”,当点击一个项目时,切换到一个新视图。这是我正在使用的代码:
<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:ms="libs/MessageBox-digitalRetro">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<s:actionContent>
<s:Button id="signin" label="Sign in" click="onSignIn(event)"/>
</s:actionContent>
//code for the clicking of the sign in button
<fx:Script>
<![CDATA[
protected function onSignIn(event:Event):void
{
}
]]>
</fx:Script>
<s:List height="100%" width="100%">
<s:itemRenderer>
<fx:Component>
<s:IconItemRenderer height="100" labelField="name"
iconField="photo" iconHeight="80"
iconWidth="80" messageFunction="getMessage">
<fx:Script>
<![CDATA[
import spark.components.NavigatorContent;
//this first method works
protected function getMessage(o:Object):String
{
return o.message;
}
]]>
</fx:Script>
</s:IconItemRenderer>
</fx:Component>
</s:itemRenderer>
<s:dataProvider>
<s:ArrayCollection>
<fx:Object name="Projects" photo="@Embed('libs/ProjectsIcon2.png')" message="Learn more about what we're working on" clickfn="views/Projects"/>
<fx:Object name="Locate Office" photo="@Embed('libs/google-maps-icon.png')" message="Find directions to our nearest office" clickfn=""/>
<fx:Object name="Contact Us" photo="@Embed('libs/gmailicon.png')" message="Let us know your thoughts!" clickfn=""/>
<fx:Object name="About Us" photo="@Embed('libs/info-icon.png')" message="" clickfn=""/>
</s:ArrayCollection>
</s:dataProvider>
<s:change>
<![CDATA[
// NEW!!!
var ClassReference:Class = getDefinitionByName(event.currentTarget.selectedItem.clickfn) as Class;
navigator.pushView(ClassReference);
]]>
</s:change>
</s:List>
</s:View>
编辑:我添加了“更改”标签,现在可以编译,但我收到一条错误消息:
ReferenceError:错误 #1065:未定义变量项目。在 global/flash.utils::getDefinitionByName() 在 views::MainHomeView/___MainHomeView_List1_change()[C:\Users\jlehenbauer\Adobe Flash Builder 4.5\Metters Inc\src\views\MainHomeView.mxml:56] 在 flash.events ::EventDispatcher/dispatchEventFunction() at flash.events::EventDispatcher/dispatchEvent() at mx.core::UIComponent/dispatchEvent()[E:\dev\4.5.1\frameworks\projects\framework\src\mx\core \UIComponent.as:13128] 在 spark.components::List/commitSelection()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\List.as:1205] 在 spark.components .supportClasses::ListBase/commitProperties()[E:\dev\4.5.1\frameworks\projects\spark\src\spark\components\supportClasses\ListBase.as:939] 在 spark.components::List/commitProperties() [E:\dev\4.5.