开发者

Click event not working flex

开发者 https://www.devze.com 2023-02-28 13:03 出处:网络
I have a list that as an arraylist as a dataprovider.It has an inline item renderer thet has image control. The click event doesn\'t work for the image ctrl.The code looks like this

I have a list that as an arraylist as a dataprovider.It has an inline item renderer thet has image control. The click event doesn't work for the image ctrl.The code looks like this

        <s:ArrayList id="allActionsArrList">
        <fx:Object click="showList('Portlet')" source="@Embed('images/bpc1.jpg')" />
        <fx:Object click="showList('Pages')" source="@Embed('images/Tab.png')"  />
        <fx:Object click="smsClick()" source="@Embed('images/launchpad_tel.png')"  />
        <fx:Object click="logoutImg_clickHandler(event)" source="@Embed('images/logoutS.swf')"  />
    </s:ArrayList>
        <s:List id="actionStripList" bottom="0" width="100%" borderColor="black"
        borderVisible="true" contentBackgroundAlpha="0" dataProvider="{allActionsArrList}"
        useVirtualLayout="false">
    <s:layout>
        <s:TileLayout/>
    </s:layout>
    <s:itemRenderer>
        <fx:Component>
            <s:ItemRenderer width="100%" height="40">
                <mx:Image buttonMode="true" horizontalCenter="0"
                                                  width="40" 开发者_如何转开发height="40" source="{data.source}" click="{data.click}"/>
            </s:ItemRenderer>
        </fx:Component>
    </s:itemRenderer>
</s:List>

Any idea.Thanks in advance!


1.You may do something like this:

<fx:Object clickHandler="{showList}" clickParams="{['Portlet']}" source="@Embed('images/bpc1.jpg')" />
<fx:Object clickHandler="{showList}" clickParams="{['Pages']}" source="@Embed('images/Tab.png')"  />
<fx:Object clickHandler="{smsClick}" clickParams="{[]}" source="@Embed('images/launchpad_tel.png')"  />
<fx:Object clickHandler="{logoutImg_clickHandler}" clickParams="{[]}" source="@Embed('images/logoutS.swf')"/>

<mx:Image buttonMode="true" horizontalCenter="0" width="40" height="40" source="{data.source}" click="data.clickHandler.apply(this, data.clickParams)"/>

Here you possibly should take care of this object (info)
But I'd used the 2nd variant.

2.Another variant is to define some attribute (id for example) for your Object items. Then you can use switch statement in your inline itemRenderer and call different listeners depending on data.id.

0

精彩评论

暂无评论...
验证码 换一张
取 消