Flex4-如何使用数据组从数组集合中获取选定的图像(鼠标单击图像)
数据组中的图库,我如何调用选定的图像(鼠标单击图像)这是我的示例代码
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import spark.components.Image;
import spark.components.TitleWindow;
[Bindable]
private var myArray:ArrayCollection= new ArrayCollection([
{image:'Assets/images/best_01.jpg'},
{image:'Assets/images/best_02.jpg'},
{image:'Assets/images/best_03.jpg'},
{image:'Assets/images/best_04.jpg'}]);
private function imageClickHandler(event:MouseEvent):void {
var imgCount:Number=0;
var image:Image= new Image();
PopUpManager.addPopUp(image,this,true);
image.source=myArray.getItemAt(imgCount).image;
}
]]>
</fx:Script>
<s:DataGroup id="dg" itemRenderer="com.ItemRenderForHorizontallist"
dataProvider="{myArray}"
verticalCenter="0"
horizontalCenter="0"
click="imageClickHandler(event)">
<s:layout >
<s:TileLayout horizontalGap="20" verticalGap="20" columnWidth="180" />
</s:layout>
</s:DataGroup>
- 此代码可以工作,但我想要选定的图像(鼠标单击图像)任何人都可以帮助我...........谢谢*
Gallery in DataGroup, How can i Call selected image(MouseClick Image) this is my Sample code
<fx:Script>
<![CDATA[
import mx.collections.ArrayCollection;
import mx.managers.PopUpManager;
import spark.components.Image;
import spark.components.TitleWindow;
[Bindable]
private var myArray:ArrayCollection= new ArrayCollection([
{image:'Assets/images/best_01.jpg'},
{image:'Assets/images/best_02.jpg'},
{image:'Assets/images/best_03.jpg'},
{image:'Assets/images/best_04.jpg'}]);
private function imageClickHandler(event:MouseEvent):void {
var imgCount:Number=0;
var image:Image= new Image();
PopUpManager.addPopUp(image,this,true);
image.source=myArray.getItemAt(imgCount).image;
}
]]>
</fx:Script>
<s:DataGroup id="dg" itemRenderer="com.ItemRenderForHorizontallist"
dataProvider="{myArray}"
verticalCenter="0"
horizontalCenter="0"
click="imageClickHandler(event)">
<s:layout >
<s:TileLayout horizontalGap="20" verticalGap="20" columnWidth="180" />
</s:layout>
</s:DataGroup>
- this code work but i want selected image(MouseClick Image) any one help me ............ thanks*
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您正在使用 imgCount 来访问 ArrayCollection 的索引;但是,您始终将其设置为 0。
您可以将 s:DataGroup 更改为 s:List,然后在单击处理程序中使用 selectedItem 属性:
You're using imgCount to access the index of your ArrayCollection; however, you always set it to 0.
You could change s:DataGroup to s:List, then use the selectedItem property in your click handler: