oops, missing this for a while
authorRichard Fairhurst <richard@systemed.net>
Mon, 3 Aug 2009 19:53:23 +0000 (19:53 +0000)
committerRichard Fairhurst <richard@systemed.net>
Mon, 3 Aug 2009 19:53:23 +0000 (19:53 +0000)
net/systemeD/halcyon/JSController.as [new file with mode: 0644]

diff --git a/net/systemeD/halcyon/JSController.as b/net/systemeD/halcyon/JSController.as
new file mode 100644 (file)
index 0000000..81a2419
--- /dev/null
@@ -0,0 +1,31 @@
+package net.systemeD.halcyon {
+    import net.systemeD.halcyon.connection.*;
+       import flash.events.*;
+    import flash.external.ExternalInterface;
+
+       /* JSController provides an interface for Halcyon to call the enclosing page, via JavaScript
+         */
+
+    public class JSController implements MapController {
+
+        private var map:Map;
+               private var jsresponder:String;                                 // JavaScript function called when user clicks
+
+        public function JSController(map:Map, jsresponder:String) {
+            this.map = map;
+            this.jsresponder = jsresponder;
+        }
+
+        public function setActive():void {
+            map.setController(this);
+        }
+
+        public function entityMouseEvent(event:MouseEvent, entity:Entity):void {
+            if ( event.type == MouseEvent.CLICK )
+                               ExternalInterface.call(jsresponder, 'click', entity.getType(), entity.id, entity.getTagsCopy());
+        }
+
+    }
+
+}
+