Tutorial / Using with Flash

Code Example 6: aIn.fla

Preparation

Connect a potentiometer to ain 0 as shown in the following schematic. Only one potentiometer is connected in the picture, but you can connect up to four potentiometers to see all analog inputs work.

Description

After receiving an "onReady" event, call the "beginAnalogInput()" method to start peeking analog inputs. When calling this method, the array analogInput[] is updated continuously until the "endAnalogInput()" 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.beginAnalogInput();
  7.     _root.onEnterFrame = function() {
  8.         for (i=0; i<gnr.analogInput.length; i++) {
  9.             _root["a"+i].text = gnr.analogInput[i];
  10.         }
  11.     }
  12. }
prev 1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13 - 14 next
Print