views:

92

answers:

1

I'm having issue to init a menu item inside of CustomEvent. It's weird I can handle any mouseEvents (click, over or out) without any problem. But NOT with Event.INIT or Event.COMPLETE.

For some reason, It doesn't fire... Does anyone know is there a better way to do that?

My code:

private function handleMenu(event:CustomEventCenter):void
{
  var menuOption = event._name.menu;

  menuOption.addEventListener(MouseEvent.CLICK, handleOptionClicked);
  menuOption.addEventListener(Event.INIT, handleInitMenuItem); // It doesn't go through!!
}

private function handleInitMenuItem(event:Event):void 
{
  var clickedItem:Array = event.target.belongsToMenu;
  selectedMenuItem = clickedItem;
  // It won't display the trace while using Event.INIT or COMPLETE. However the trace works fine when I use MouseEvent
  trace("____selectMenuItem: "+selectedMenuItem[0]);
 }

In my Menu class: I defined menuItem is just a MovieClip

dispatchEvent(new CustomEventCenter(CustomEventCenter.OBJECT_USED, { menu:menuItem }));
A: 

What would cause and INIT or COMPLETE event to fire from menuOption once your CustomEventCenter event is fired? It could be that these events are occurring before the CustomEventCenter event. What is menuOption supposed to be an instance of? Can you share some more code? perhaps the area where you are adding the event CustomerEventCenter handler.

Chris Gutierrez