Howto removeEventListener with ?

2019-08-16 11:01发布

I'm trying to remove an eventlistener on (in this specific case) a HorizontalList. The list is initialized with the property

itemRollOver="playPreview(event)"

I'd like to remove this eventListener by switching state and stating something like:

<mx:SetEventHandler target="{horList}" name="itemRollOver" handlerFunction="null" />

This doesn't seem to work. The event is still handled and playPreview(event:ListEvent) is still called. How to properly do this? (I know I can do it in Actionscript, but I specifically want to do it by means of state switching)

Cheers Bart

1条回答
相关推荐>>
2楼-- · 2019-08-16 11:23

AFAIK you can only remove listeners that were added with AS, not ones added with mxml. So you should remove the listener from the mxml, on creationComplete of your app use AS to add the event listener, then whatever you do to cause your state to switch can fire an AS function to remove it.

Of the top of my head the code is something like this:

HList.addEventListener(MOUSE_EVENT.RollOver,nameOfRollOverFunction);
HList.removeEventListener(MOUSE_EVENT.RollOver,nameOfRollOverFunction)
查看更多
登录 后发表回答