I built a custom event manager that passes variables. I send an event and then try to listen to the event at the root of my document, but I never get this event. How do I bubble an event before my document class?
addEventListener(CustomVarEvent.pinClicked, pinClickedHandler);
function pinClickedHandler(e:CustomVarEvent) {
trace("main says " + e.arg[0] + " clicked");
}
package zoomify.viewer
{
import com.maps.CustomVarEvent;
protected function hotspotClickHandler(event:MouseEvent):void {
var hotspotData:Hotspot = hotspotsMap[event.currentTarget] as Hotspot;
trace(hotspotData._name + " was clicked");
dispatchEvent(new CustomVarEvent("pinClicked",true,false,hotspotData._name));
}
}
package com.maps
{
import flash.events.Event;
public class CustomVarEvent extends Event {
public static const pinClicked:String = "pinClicked";
public var arg:*;
public function CustomVarEvent(type:String, ... a:*) {
var bubbles:Boolean = true;
var cancelable:Boolean = false;
super(type, bubbles, cancelable);
arg = a;
}
override public function clone():Event{
return new CustomVarEvent(type, arg);
};
}
}
The pinClicked event that is dispatched is nested two levels deep in the classes. I am adding an instance of the ZoomifyViewer class to the scene. ZoomifyViewer adds a ZoomGrid instance to the scene, and ZoomGrid dispatches an event.
ZoomGrid ( , ), . , , .
?
, pinClicked, CustomVarEvent?
dispatchEvent(new CustomVarEvent(CustomVarEvent.pinClicked, hotspotData._name));
dispatchEvent(new CustomVarEvent("pinClicked", hotspotData._name));