我创建了这个类,它是一个ItemRenderer类,用于DataGroup(移动应用程序), 我不完全确定我是否做对了,我的问题是:
以下是该课程的功能,非常感谢任何帮助!!
将其声明为简单图像:
var logo:Image;
覆盖createChildren
logo = new Image();
addChild(logo);
我在set Data
logo.source = "http://192.168.0.15:3000/"+value.logo_thumb_url;
尺寸
override protected function measure():void {
measuredWidth = measuredMinWidth = stage.fullScreenWidth;
measuredHeight = measuredMinHeight = 100;
}
监听
override public function set data(value:Object):void {
tel.text = String(value.Tel);
description.text = String(value.Descricao);
nome.text = String(value.Nome);
logo.addEventListener(MouseEvent.CLICK, function():void{
var service:HTTPService = new HTTPService();
service.url = value.targer;
service.method = "GET";
// setting headers and other variables ...
service.send();
});
}
答案 0 :(得分:1)
有一些建议,你编码的是好的,但是,不是在设置数据上添加监听器,而是在创建完成时添加它,因为它更合适。此外,事件侦听器必须是弱引用,http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/events/EventDispatcher.html#addEventListener()