ActionScript 3 Remove All Events with no reference or name

I wanted to find a way to remove event listeners without knowing the reference to them – so i asked my dear friend google – wich gave me alot of posts about how to add global references to your listeners with use of dictionary or EventManager classes – so i tried to dig into describeType because i knew it somehow could tell me everything i needed to know about a class – and yes here was the answer: as a part of the xml that was returned was this code:

<method name=”onFrame” declaredBy=”_something_fla::background_2″ returnType=”*”>
<parameter index=”1″ type=”” optional=”false”/>

it cearly states that here is a function, it is NOT declared by flash.classes wich all other built in functions are – and it gives me the Event type – so by doing some simple conditional xml parsing i came up with this:

var listenerXml:XML = XML(describeType(_mc));
for each (var object:XML in XMLList(listenerXml..method)) {if(object.@declaredBy.toXMLString().substr(0,6) != "flash.") {
var typeStr:String = object.parameter.@type.toXMLString();
trace("event type: "+(typeStr.substr(14,typeStr.length)));
trace("method you have created: "+object.@name.toXMLString())


One thought on “ActionScript 3 Remove All Events with no reference or name

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s