views:

118

answers:

1

Hi there,

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  A: 

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)
invertedSpear
Thanks, then I'll stick to AS.In the meantime I patched the problem by setting the property "mouseEnabled" to "false" when switching from state to state.The thing that's left is: what is `<mx:SetEventHandler />` for? Its name implies some sort of manipulation of eventHandlers.
Brelsnok
I've never seen it before. Maybe just ask that question with a link back to this one, and see if anyone can give you more detail on it.
invertedSpear