topical media & game development

talk show tell print

actionscript-phidget-system-PhidgetDictionaryTest.ax

actionscript-phidget-system-PhidgetDictionaryTest.ax [swf] flex


  package
  {
          import com.phidgets.*;
          import com.phidgets.events.*;
          
          import flash.display.Sprite;
                  
          public class @ax-actionscript-phidget-system-PhidgetDictionaryTest extends Sprite {
                  
                  private var phid:PhidgetDictionary;
                  private var keyListener:PhidgetDictionaryKeyListener;
                  
                  public function @ax-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);
                  }
          }
  }


(C) Æliens 27/08/2009

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.