Need help on my coding, actionscript, phidgets

Legacy support with Phidget21
Phidgetkort
Fresh meat
Posts: 1
Joined: Wed Mar 14, 2012 5:26 am
Contact:

Need help on my coding, actionscript, phidgets

Postby Phidgetkort » Wed Mar 14, 2012 5:39 am

Hello,

Im working on a school project, and thought I needed some programming of actionscript+phidgets to get a cool result.

But im having some problems with the programming.

The idea:
I got 3LED's , each connected to a button.
The leds go and light up in random turns for a short time, and you have to press the correct button fast enough that is connected to the LED that is on. If you hit the good 1 , then that light will stay on and then there are 2 LED's left. etc.
Its like a game, in the 'wack a mole' style.


Now our actionscript:

package ActionScript
{
import flash.display.MovieClip;
import flash.utils.*;
import com.phidgets.*;
import com.phidgets.events.*;


var spelSnelheid:int
var spelScore:int
var spelInterval:uint

var phid:PhidgetInterfaceKit

var lamp1Actief:Boolean
var lamp1Aan:Boolean

var lamp2Actief:Boolean
var lamp2Aan:Boolean

var lamp3Actief:Boolean
var lamp3Aan:Boolean

function main(){
phidVerbinding()
instellen()
}
function phidVerbinding(){
phid = new PhidgetInterfaceKit();
phid.open("localhost", 5001);
phid.addEventListener(PhidgetDataEvent.INPUT_CHANGE, inputChange);
}
function instellen(){
spelSnelheid = 1 spelScore = 0

lamp1Actief = true
betekend dat de lamp meedoet aan het spel
lamp1Aan = false
betekend dat het lampje aan is

lamp2Actief = true
lamp2Aan = false

lamp3Actief = true
lamp3Aan = false
spelInterval = setInterval(stap,spelSnelheid);
}

function stap(){
lampen()
if(spelScore == 3){
spelAfgelopen()
trace(spelScore);
}
}
function spelAfgelopen(){
clearInterval(spelInterval);
afgelopen()
setTimeout(instellen,1000)
trace("afgelopen")
}

function afgelopen(){

}
function inputChange(evt:PhidgetEvent){
trace(evt);

if (phid.getInputState(0)){
if(lamp1Aan){
lamp1Actief = false
trace("lamp 1 is uit het spel!")
}
}
if (phid.getInputState(1)){
if(lamp2Aan){
lamp2Actief = false
trace("lamp 2 is uit het spel!")
}
}
if (phid.getInputState(2)){
if(lamp3Aan){
lamp3Actief = false
trace("lamp 3 is uit het spel!")
}
}
}
function lampen(){
if(lamp1Actief){
if(Math.round(Math.random()) == 0 ){
//trace("lamp 1 Aan")
lamp1Aan = true
spelScore = spelScore +1
}else{
//trace("lamp 1 uit")
lamp1Aan = false
}
phid.setOutputState(0, lamp1Aan);
}

if(lamp2Actief){
if(Math.round(Math.random()) == 0 ){
//trace("lamp 2 Aan")
lamp2Aan = true
spelScore = spelScore +1
}else{
//trace("lamp 2 uit")
lamp2Aan = false
}
phid.setOutputState(1, lamp2Aan);
}

if(lamp3Actief){
if(Math.round(Math.random()) == 0 ){
//trace("lamp 3 Aan")
lamp3Aan = true
spelScore = spelScore +1
}else{
//trace("lamp 3 uit")
lamp3Aan = false
}
phid.setOutputState(2, lamp3Aan);
}
}
}
}






THAT was the actionscript.
Now the error is saying , that we have a } to much.
But no matter how we change the amounts of '{' and '}' , it just wont be correct.

Can anyone please help me with this

bcraig77
Phidgetsian
Posts: 6
Joined: Fri Mar 09, 2012 4:41 pm
Contact:

Re: Need help on my coding, actionscript, phidgets

Postby bcraig77 » Wed Mar 14, 2012 7:46 am

Try this. You also had two comments (betekend dat de lamp meedoet aan het spel) that needed to be commented out.
Attachments
Script-1.as.zip
(1.2 KiB) Downloaded 289 times


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

Who is online

Users browsing this forum: No registered users and 1 guest