Phidget Dictionary Service code samples

Legacy support with Phidget21
IanC

Phidget Dictionary Service code samples

Postby IanC » Mon Jun 20, 2011 11:41 am

Hi,

Does anybody know if there are any code samples for accessing the Phidget Dictionary Service. I cant find any examples for AS3 anywhere.

Thanks for any assistance anyone can offer.

User avatar
Patrick
Lead Developer
Posts: 3177
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: Phidget Dictionary Service code samples

Postby Patrick » Mon Jun 20, 2011 12:43 pm

Very basic, but:

Code: Select all

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


-Patrick

IanC

Re: Phidget Dictionary Service code samples

Postby IanC » Mon Jun 20, 2011 1:33 pm

Thanks Patrick thats just what i was looking for

Ian


Return to “ActionScript 3.0 - Flash CS3 / Flex / AIR”

Who is online

Users browsing this forum: No registered users and 1 guest