package { import com.phidgets.*; import com.phidgets.events.*; import flash.display.Sprite; public class actionscript_phidget_system_PhidgetDictionaryTest extends Sprite { private var phid:PhidgetDictionary; private var keyListener:PhidgetDictionaryKeyListener; public function actionscript_phidget_system_PhidgetDictionaryTest() { phid = new PhidgetDictionary(); phid.addEventListener(PhidgetDictionaryEvent.CONNECT, onConnect); phid.addEventListener(PhidgetDictionaryEvent.DISCONNECT, onDisconnect); phid.addEventListener(PhidgetErrorEvent.ERROR, onError); phid.open("localhost", 5001); keyListener = new PhidgetDictionaryKeyListener(phid, ".*"); keyListener.addEventListener(PhidgetDictionaryEvent.KEY_CHANGE, onKeyChange); keyListener.addEventListener(PhidgetDictionaryEvent.KEY_REMOVAL, onKeyRemoval); } private function onError(evt:PhidgetErrorEvent):void { trace(evt); } private function onKeyChange(evt:PhidgetDictionaryEvent):void{ trace(evt); } private function onKeyRemoval(evt:PhidgetDictionaryEvent):void{ trace(evt); } private function onConnect(evt:PhidgetDictionaryEvent):void{ trace(evt); keyListener.start(); phid.addKey("hi", "there"); } private function onDisconnect(evt:PhidgetDictionaryEvent):void{ trace(evt); } } }