Help needed "Voltage and Current Sensors"

Legacy support with Phidget21
Hannamja
Phidgetsian
Posts: 11
Joined: Tue Oct 02, 2012 2:13 am
Contact:

Help needed "Voltage and Current Sensors"

Postby Hannamja » Tue Oct 02, 2012 2:21 am

Hi guys,

I just started using Phidgets for my project. However, I do not have any knowledge of phidgets and I couldn't get things working even after trying out for 2 days.

I have attached a picture of my error. I could not get Flash to show that the Phidgets is connected. I am using 1018_2, 1122 and 1135.


If possible, can someone provide me with a actionscript code that can obtain the values being captured by the sensors and allow me to use the values for further calculation in flash.

Thanks!
Attachments
Error.PNG
(126.39 KiB) Not downloaded yet

erik
King of the Lab
Posts: 476
Joined: Fri Mar 06, 2009 12:42 pm
Location: Calgary, Canada
Contact:

Re: Help needed "Voltage and Current Sensors"

Postby erik » Tue Oct 02, 2012 8:01 am

While I don't know much about Flash, it seems that you are trying to use the PhidgetAnalog object instead of the PhidgetInterfaceKit.

The PhidgetAnalog object and example is used for the 1002_0 board, and the PhidgetInterfaceKit object and example is used for the 1018_2 board.

Hannamja
Phidgetsian
Posts: 11
Joined: Tue Oct 02, 2012 2:13 am
Contact:

Re: Help needed "Voltage and Current Sensors"

Postby Hannamja » Tue Oct 02, 2012 9:31 am

Thanks man! Flash is working with phidgets now. But only the .FLA file seems to be working. The .swf doesn't work correctly like the .fla file. Any idea why?

To try and capture the value being shown in sensor 0 to Flash, I added a line of command as shown in the picture attached. Anyone know what I did wrong? If possible, can someone please help me to reduce the program so something such that only TWO sensors values will be captured from the Phidgets board will be captured and sent to Flash?

Thanks in advance!
Attachments
PhidgetsSensors.PNG
(121.93 KiB) Not downloaded yet

Hannamja
Phidgetsian
Posts: 11
Joined: Tue Oct 02, 2012 2:13 am
Contact:

Re: Help needed "Voltage and Current Sensors"

Postby Hannamja » Wed Oct 03, 2012 2:47 am

I tried to code the program such that only Sensor 1 will be captured and displayed in a textbox in Flash. Here is the code:

import com.phidgets.PhidgetInterfaceKit;
import com.phidgets.events.*;

var current:int;
myText.border = true;

var phid:com.phidgets.PhidgetInterfaceKit;
phid = new PhidgetInterfaceKit();
phid.open("localhost", 5001);

phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, onSensorChange);
function onSensorChange(evt:PhidgetDataEvent):void{
function getSensorValue( 1 : int ):int
{ current = getsensorvalue[1]
myText.text = current.toString();
}
trace (evt.Data); //Echo
}


When I test the program, it just shows a blank screen. Anyone knows what I'm doing wrong?

I am really confused as to what I am doing. Some additional information, the sensor values are constant at 499 and 487. Is the error occuring because of the fixed value?


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

Who is online

Users browsing this forum: No registered users and 1 guest