PDA

View Full Version : error 1119, 1120, 1136


ofranko
10-02-2010, 03:21 PM
i'm working on an interactive spelling activity for 1st graders.
a friend has offered me some help (he's not available today) and i'm stuck.

i have 3 buttons :
letterA
letterC
letterT

when i click the correct on function "correct" is called
if incorrect function "incorrect" is called

i've attached my code, timeline, and compiler errors

i think i've left something out

can someone help find my errors?

thanks,
frank





function addObjectListeners():void{


letterC.answerType = "correct"
letterC.answerText = "C"
letterC.addEventListener(MouseEvent.CLICK, clickAnswer);
letterA.answerType = "incorrect"
letterA.addEventListener(MouseEvent.CLICK, clickAnswer);

letterT.answerType = "incorrect"
letterT.addEventListener(MouseEvent.CLICK, clickAnswer);

}

//for your code example it should be this...

function clickAnswer(event:MouseEvent):void{
var answer:String = event.target.answerType;

switch(answer){

case "correct":
correct(); //call correct function
case "incorrect":
incorrect(); //call incorrect function for all others
default:
incorrect(); //default to incorrect function for all others


}
}
function correct(obj:Object){
frstLetter.text = obj.answerText;
}
function incorrect(){
frstLetter.text = "*";
}

lostvoices
10-04-2010, 06:07 AM
hey man

don't know much about AS but i'll give it a shot..

don't know if this makes a difference baut

function correct(obj:Object){
frstLetter.text = obj.answerText;
}


correct requires an Object passed in.

when you call it in your switch staement.. correct(); you don't pass an object in

but again this may be nothing :P