singleLED.fla not working
Up to Flash
singleLED.fla is the only example that sets the DefaultBoard to a specific ip in the onBoardArrived function.
If the ip listed there isn't the correct ip there will be no lights for you ; )
Just comment out the: if( newBoard.location == "x.x.x.x" )
I've had the same problem with the singleLED example file not working -- even
when commenting out that line of code in the "onBoardArrived" method.
The LEDchaser.fla example, which appears to be working correctly, uses the
sendBundle() method, rather than the send() and sendMessage() methods
that the singleLED.fla example is using.
Not sure what's causing it, yet. I'm currently working with the
controller via USB on OSX (Leopard) in Flash CS3 with the AS3 libraries.
-John
OK, I got the singleLED.fla example working.
My problem was that the default board property wasn't being set correctly when the onBoardArrived() method was called. The IP address used in the example code was an issue for me as I'm using USB to work with the board. I just used the reference of the board being passed in with the onBoardArrived() method (instead of keying it to the IP address) to make it work. I've pasted my updated code below:
// Making Things 2006
// LED Control - turn an LED on the Application Board on and off.
import com.makingthings.makecontroller.*; // import the MakingThings library
//
addEventListener( Event.ENTER_FRAME, eachFrame );
//
var mcFlash:McFlashConnect = new McFlashConnect( ); // our connection to mchelper
mcFlash.addEventListener( McEvent.ON_BOARD_ARRIVED, onBoardArrived );
mcFlash.connect( );
var boxState:Boolean;
//
function onBoardArrived( event:McEvent )
{
// commenting out problematic example code
/*
var newBoard:Board = event.data;
//if( newBoard.location == "192.168.0.121" ) mcFlash.setDefaultBoard( newBoard );
trace( 'onBoardArrived(), location: ' + newBoard.location );
*/
var newBoard:Board = event.data;
mcFlash.setDefaultBoard( newBoard );
}
//
function eachFrame( e:Event )
{
if( checkbox.selected != boxState ) //if the checkbox has changed
{
if( checkbox.selected ) // if it's selected, turn the LED on
{
var msg = new OscMessage( "/appled/0/state", [1] );
mcFlash.sendMessage( msg );
}
else
{
// otherwise turn it off
mcFlash.send( "/appled/0/state", [0] );
//boxState = checkbox.selected; //store the state for the next comparison
}
//
boxState = checkbox.selected;
}
}

