AS3 Timer disables phidget, How can I correct that?

Legacy support with Phidget21
Gritchu
Fresh meat
Posts: 2
Joined: Thu Jan 15, 2015 9:11 am
Contact:

AS3 Timer disables phidget, How can I correct that?

Postby Gritchu » Thu Jan 15, 2015 9:31 am

Greetings,

I have an 8/8/8 Phidget connected to my computer via usb. My Flash CS5 AS3 code is pretty simple. I copied the code directly from the simple sample file provided by phidgets.com to interface with the phidget. Afterwards I have added a timer that runs another function further down in the script at set intervals. At this time no part of my code outside the sample code i copied interacts with the phidget.

When I run the FLA file the phidget works briefly then stops responding after a moment.
When I comment out the listener on the timer and still start the timer, the phidget works briefly then stops responding.
When I comment out imageTimer.start(); line and run it, the phidget doesn't disconnect and works as intended. Except I need that timer.

Code: Select all

var phid:PhidgetInterfaceKit;
         
phid = new PhidgetInterfaceKit();
         
phid.addEventListener(PhidgetEvent.CONNECT, onConnect);
phid.addEventListener(PhidgetEvent.DISCONNECT, onDisconnect);
phid.addEventListener(PhidgetEvent.DETACH, onDetach);
phid.addEventListener(PhidgetEvent.ATTACH, onAttach);
phid.addEventListener(PhidgetErrorEvent.ERROR, onError);
phid.addEventListener(PhidgetDataEvent.INPUT_CHANGE, onInputChange);
phid.addEventListener(PhidgetDataEvent.OUTPUT_CHANGE, onOutputChange);
phid.addEventListener(PhidgetDataEvent.SENSOR_CHANGE, onSensorChange);

// All appropriate functions to the above listeners are included with traces in them.

phid.open("localhost", 5001);

imageTimer = new Timer( 1000 );
imageTimer.addEventListener( "timer", importImages );
imageTimer.start(); // Commenting this line allows the phidget to continue to run without interruption.


Any help would be appreciated.

Gritchu
Fresh meat
Posts: 2
Joined: Thu Jan 15, 2015 9:11 am
Contact:

Re: AS3 Timer disables phidget, How can I correct that?

Postby Gritchu » Thu Jan 15, 2015 5:08 pm

As it turns out. I traced the issue into the function that executes from the timer after all. The timer was executing so quickly that I think it was hogging all the system resources needed to run the phidget properly.


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

Who is online

Users browsing this forum: No registered users and 1 guest