Sections
You are here: Home Forum Flash singleLED.fla not working

singleLED.fla not working

Up to Flash

singleLED.fla not working

Posted by cara thompson at March 24. 2008
I just got my board and installed everything and am going through the tutorials for AS3. I got the LED chaser to work, but cannot get the singleLED.fla to work. I can turn the led on and off in the mcHelper (manually) but the checkbox in the downloaded tutorial file won't work. No errors, no output in the mcHelper output box. Just nothing. Seems like a few people have had this problem, but I can't seem to find an answer. If you had this problem, please let me know how you fixed it.

Re: singleLED.fla not working

Posted by g.j. van Trier at March 25. 2008

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" )

Re: singleLED.fla not working

Posted by john hendricks at June 04. 2008

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

Re: singleLED.fla not working

Posted by john hendricks at June 04. 2008

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;
    }
}



Re: singleLED.fla not working

Posted by ben rigby at July 06. 2008
thanks for the fix!
Powered by Ploneboard
Document Actions