带 ItemRenderer 的 Spark 列表单击功能不起作用
我的 ItemRenderer 遇到问题,我将其用于 Spark 列表。我的代码如下:
我有这个列表:
<s:List
id="productSetList"
dataProvider="{ model.productSets }"
change="model.selectSet( productSetList )"
height="100%" width="100%"
borderVisible="false"
itemRenderer="SideBarItemRenderer" top="20" left="15">
</s:List>
我的 itemRenderer 是:
<s:ItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
width="160" height="175" autoDrawBackground="false" buttonMode="true" useHandCursor="true"
click="click(event)" cacheAsBitmap="true"
>
<fx:Script>
<![CDATA[
import com.png.vm.model.vos.ProductSet;
protected function click(event:MouseEvent):void
{
trace('arthur');
}
]]>
</fx:Script>
<s:BitmapImage source="{ProductSet(data).image}" width="160" height="175"/>
</s:ItemRenderer>
问题是,如果我滚动列表并单击一个项目,它不会跟踪 'arthur' !为什么会这样呢?我必须跟踪有人点击列表的所有时间!
编辑: 如果我删除列表中的 change="model.selectSet( ProductSetList )"
,它就会起作用!但我无法删除它,一些建议?我怎样才能将其切换到另一个功能?
I am having an issue with my ItemRenderer, which I am using for a spark List. My code is the following:
I have this list:
<s:List
id="productSetList"
dataProvider="{ model.productSets }"
change="model.selectSet( productSetList )"
height="100%" width="100%"
borderVisible="false"
itemRenderer="SideBarItemRenderer" top="20" left="15">
</s:List>
and my itemRenderer is:
<s:ItemRenderer
xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
width="160" height="175" autoDrawBackground="false" buttonMode="true" useHandCursor="true"
click="click(event)" cacheAsBitmap="true"
>
<fx:Script>
<![CDATA[
import com.png.vm.model.vos.ProductSet;
protected function click(event:MouseEvent):void
{
trace('arthur');
}
]]>
</fx:Script>
<s:BitmapImage source="{ProductSet(data).image}" width="160" height="175"/>
</s:ItemRenderer>
The thing is, if I scroll the list, and click on an item, it does not trace 'arthur' ! Why is this so ? I must trace that all the time that someone clicks in the list!
EDIT:
If I remove change="model.selectSet( productSetList )"
in the list, it works!! but I cannot remove that, some suggestions ? How can I switch that to another function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
仅当您正在调试/使用 Flash Player 的调试版本时,跟踪才起作用。确保你正在使用它。如果您想要弹出消息,请使用
Alert.show("message")
有关trace()的更多信息请查看:
http://livedocs.adobe.com/flex/3 /html/help.html?content=logging_08.html
和 Alert.show(): http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001965.html
如果您正在运行调试播放器。尝试从嵌入的
发起点击事件,这样您在位图之外添加的任何内容仍然会触发点击事件。比如:
我之前确实在 ItemRenderers 中让点击事件对我有用过
Trace only works when you are debugging/using the debugging version of Flash Player. Make sure you are using that. If you want a pop-up message use
Alert.show("message")
For more information about trace() check out:
http://livedocs.adobe.com/flex/3/html/help.html?content=logging_08.html
And Alert.show(): http://help.adobe.com/en_US/AS2LCR/Flash_10.0/help.html?content=00001965.html
If you are running debug player. Try originating the click event from an embedded
<s:Group>
this way whatever you add in here beyond the bitmap will still trigger the click event.Something like:
I've definitely had click events work for me inside of ItemRenderers before
抱歉,我终于解决了。问题是在函数
model.selectSet
中,我调用了 List.change;我把清单弄乱了!我的功能如下:所以,我刚刚删除了这一行:
list.layout.verticalScrollPosition=100;
,现在它工作正常。感谢您的帮助!
My apologies, I have finally solved it. The problem was that inside the function,
model.selectSet
, I was calling List.change; I was messing the list up! My function was as follows:So, I just removed the line :
list.layout.verticalScrollPosition=100;
and now it`s working fine.Thanks for all the help!