Scaling Movieclip according to the input from sensor

70 Views Asked by At

I am new to adobe flash community and new on using the flash language, so pardon me about it.

I am currently trying to send data from the pressure sensor through Arduino and display it on flash. Don't worry about the sensor and Arduino side of it since I have done the coding and communication part of it to flash, now I am trying to do is when the user press the sensor to have the circle ball [movieclip] to scale and expand the size according to the amount of pressure input from the sensor.

Below is the code I have done so far for the scaling and hopefully is on track, I use the width and height to adjust the size however I received an error that said "call to possibly undefined method CircleGreen". Any ideas on what to do is greatly appreciate it , I will play around and let you know if I fix the problem.

Thank you

var circleGreen = new CircleGreen();

a.addEventListener(ArduinoEvent.ANALOG_DATA, onTickk);

function onTickk(e:ArduinoEvent):void{

  var feetValue:int;
  feetValue = a.getAnalogData(0);  //to get the data from the sensor

  circleGreen.x = -circleGreen.width / 2 + 312;
   circleGreen.y = -circleGreen.height / 2 + 188;

  circleGreen.width = feetValue / 40 ;
  circleGreen.height = feetValue / 40 ;

  addChild(circleGreen);

}
1

There are 1 best solutions below

6
On

try:

var circleGreen = new MovieClip();

addChild(circleGreen);   
//you can hide it with: circleGreen.visible = false;
a.addEventListener(ArduinoEvent.ANALOG_DATA, onTickk);    

function onTickk(e:ArduinoEvent):void{

  var feetValue:int;
  feetValue = a.getAnalogData(0);  //to get the data from the sensor

  circleGreen.x = -circleGreen.width / 2 + 312;
   circleGreen.y = -circleGreen.height / 2 + 188;

  circleGreen.width = feetValue / 40 ;
  circleGreen.height = feetValue / 40 ;
}

'onTickk' creates new green circle when is called, so you have to create it first or remove last one