This example documents how you can capture events.
What basically happens is we :
| You need to upgrade your Flash Player. |
this.publicInterfaceLoaded = function() { // ... }
We wait for the flash component to start, so we know when the public interface is ready.
When the flash component has started (in the publicInterfaceLoaded() function) we add some event listeners :
this.publicInterfaceLoaded = function() { var ofm = document.getElementById("ofm"); ofm.addEventListener("loadedNewView", "newView"); ofm.addEventListener("activeModeChanged", "newMode"); }
| Event | Function to notify |
|---|---|
| loadNewView | “newView” |
| activeModeChanged | “newMode” |
A listing of all available modes can be found here.
A listing of all events van be found
.
We don't add the measure listener yet. When the publicInterfaceLoaded() function is called, the component itself is ready, but the overlays (ex.: measure overlay) are not, so we cannot add a listener here. The measure listener is added when the measure mode is first activated.
var ofm; this.newView = function() { addToListing("[view] loaded"); } this.newMeasure = function() { addToListing("[measure] : "+ ofm.getMeasurementsCount() +" measurements"); } this.newMode = function(mode) { addToListing("[mode] "+ mode); if (mode=="measure" && listeningToMeasure==false) { ofm.addEventListener("measurementsChanged", "newMeasure"); listeningToMeasure = true; } } this.addToListing = function(message) { var events = document.getElementById("eventListing"); events.innerHTML += message +"<br/>"; }
These functions are the event handlers for the events we specified (view, mode and measure).