Tutorial / Using with Flash

Code Example 5: dIn.fla

Preparation

Connect a tact switch to din 0 as shown in the following schematic. Only one switch is connected in the picture, but you can connect up to four switches to see all digital inputs work.

Description

After receiving an "onReady" event, call the "beginDigitalInput()" method to start peeking digital inputs. When calling this method, the array digitalInput[] is updated continuously until the "endDigitalInput()" method is called.

  1. import gainer.*;
  2.  
  3. var gnr:Gainer = new Gainer("localhost", 2000, Gainer.MODE1, true);
  4.  
  5. gnr.onReady = function() {
  6.     gnr.beginDigitalInput();
  7.     _root.onEnterFrame = function() {
  8.         for (i=0; i<gnr.digitalInput.length; i++) {
  9.             _root["d"+i].text = gnr.digitalInput[i];
  10.         }
  11.     }
  12. }
prev 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 next
Print