package com
{
public class gallery_folio extends MovieClip
{
var image_xml:XML;
var xml_loader:URLLoader;
public var text_style:TextFormat = new TextFormat("Verdana",10,0x333333,"",null,null,null,null,"left");
public var _style:TextFormat = new TextFormat("Verdana",11,0x333333,"",null,null,null,null,"left");
public function gallery_folio()
{
xml_loader = new URLLoader(new URLRequest("xml/gallery_folio.xml"));
xml_loader.addEventListener(Event.COMPLETE,xml_loaded);
}
public function xml_loaded(e:Event):void
{
image_xml = new XML(e.target.data);
var menu_mc:MovieClip;
var menu_uldr:UILoader;
var label_:TextField;
for (var i=0; i<image_xml.children().length(); i++)
{
menu_mc=new MovieClip();
menu_mc.graphics.beginFill(0xffffff,1);
menu_mc.graphics.lineStyle(0.25,0xcccccc);
menu_mc.graphics.drawRect(0,0,100,70);
menu_mc.graphics.endFill();
addChild(menu_mc);
menu_uldr=new UILoader();
menu_uldr.source = image_xml.children()[i]. @ img;
menu_uldr.width = 100;
menu_uldr.height = 70;
menu_mc.addChild(menu_uldr);
menu_mc.y = stage.stageHeight / 15;
menu_mc.x = 10 + 120 * i;
menu_mc.buttonMode = true;
menu_mc.name = image_xml.children()[i]. @ name;
menu_mc.addEventListener(MouseEvent.CLICK,onclick_menu);
label_=new TextField();
label_.text = image_xml.children()[i]. @ name;
menu_mc.addChild(label_);
label_.selectable = false;
label_.setTextFormat(text_style);
}
}
public function onclick_menu(e:MouseEvent):void
{
trace(e.target.name);
}
}
}输出基于结构化数据的xml。
<item img="img/img_1.jpg" name="websites">
<subitem name="m1">
<image></image>
<link>http://dasmenonphotography.com</link>
<description></description>
</subitem>
<subitem name="-n-">
<image></image>
<link>http://auctussolutions.com</link>
<description></description>
</subitem>
</item>
<item img="img/img_2.jpg" name="paintings">
<subitem name="-n-">
<image></image>
<link>http://dasmenonphotography.com</link>
<description></description>
</subitem>
<subitem name="-n-">
<image></image>
<link>http://auctussolutions.com</link>
<description></description>
</subitem>
</item>
<item img="img/img_3.jpg" name="paintings">
<subitem name="-n-">
<image></image>
<link>http://dasmenonphotography.com</link>
<description></description>
</subitem>
<subitem name="-n-">
<image></image>
<link>http://auctussolutions.com</link>
<description></description>
</subitem>
</item>
</showcase>每当我单击menu .the event listen from uiloader和text字段时,我想从above.Actually中删除事件侦听程序,我想创建xml图库.with大量图像
发布于 2011-12-12 00:33:23
您所要求的是能够:
中删除该事件侦听器
您可以通过使用"currentTarget“获得对被单击目标的引用,它引用了被单击的实例(而不是被单击的特定元素,即" target ")。
您可以通过调用the "removeEventListener" method来删除eventlistener,该方法将事件类型和要删除的事件方法作为参数。
对于您的情况,以下是解决问题的方法:
public function onclick_menu(e:MouseEvent):void
{
e.currentTarget.removeEventListener(MouseEvent.CLICK, onclick_menu);
}https://stackoverflow.com/questions/8464463
复制相似问题