I cant remove Event of rute_button, rute_button.removeEventlistener is not work.
is there something wrong about function tampil_rute(t) ? thanks..
function tampil(t)
{
rute_button.addEventListener(MouseEvent.CLICK, tampil_rute(t));
//tampil_rute(t);
var _loadertampil:URLLoader = new URLLoader();
var _datatampil:XML = new XML();
_loadertampil.addEventListener(Event.COMPLETE, readXMLtampil);
_loadertampil.load(new URLRequest("http://localhost/mall_baru/tampil2.php?id="+t));
function readXMLtampil(evttampil:Event)
{
_datatampil = new XML(evttampil.target.data);
var tampilanx = _datatampil..tenant_name;
tampilan.text = String(tampilanx);
trace("tampilan ="+tampilanx);
}
}
function tampil_rute(t)
{
return function( f:MouseEvent )
{
var c = t.split("_", 2);
var d:String = String(c[0]);
var e:Number = Number(c[1]);
for(var i:Number=1; i<=e; i++)
{
tambahan_tampil_rute(d,i);
}
rute_button.removeEventListener(MouseEvent.CLICK, tampil_rute(t));
}
}
function tambahan_tampil_rute(d, i)
{
this["rute_"+d+"_"+i].visible=true;
}
The problem is in the returned function by
tampil_rute(t), each time you call this function this is returning a new object of type Function, if you want to remove the event listener, you must be sure to pass the same object (Function) to theremoveEventListenerfunction.You can fix it as follow: