December 01, 2003

Phidgets: they are alive!


whoohoo! It works! I'm having flash talk to Phidgets and all the way around!
My crappy VB is giving me headaches, but luckily once the exe wrapper is done I won't have to care about VB anymore. The plan is building a base executable which connects and talks directly to the Phidgets components. Then you'll be able to load a swf which holds all the counter part AS components that already know how to talk to that wrapper's API.

I'm still half way through it, though tonight I could finally make a very simple working sample.

So, right now, in flash it goes as simple as:

#include "PhidgetLib.as"

pm = new PhidgetManager()
servo = pm.getServo(0)
servo._rotation = random (180)

Simple huh?!

Well, I'm running into some troubles, trying to queue events before the actual connection is finished. Problem is that all this kind of connections are asynchronous right? So when I invoke new PhidgetManager(), and right in the next lines I get the servo and modify it's _rotation property, the connection to the servo might not be built yet, so I have to catch that, queue that request, and execute it when the connection is finished.

If I can't do it, then it will have to look slightly different, which may add a couple of extra lines. something like:

#include "PhidgetLib.as"

pm = new PhidgetManager()
pm.onConnect = function (phidget) {
servo = pm.getServo(0)
servo._rotation = random (180)
}
pm.connect()

I'm trying to make it as simple as possible from flash, and leave all the hard core stuff to be figured out inside PhidgetManager... but still...ain't that bad huh?

Posted by marumushi at December 1, 2003 12:43 AM
Comments
Post a comment









Remember personal info?