javascript - How to change the text in textbox depending on another textbox -
basically creating simple quiz on flash cs6 using action script 3.0 , have made following "prototype" model calculating score , giving feedback depending on it:
var xx:number = 0; button1.addeventlistener(mouseevent.click, buttoncount); function buttoncount(event:mouseevent) { xx = xx +1; var xxx:string = string(xx); score.text = xxx } if (score.text == "1"){ feedback.text == "well done"; } button1 correct answer increase score 1. "1" , "well done" examples. score.text score displayed. , feedback.text feedback. plan use other "else if" give feedback on different scores. both text boxes dynamic text.
i'm pretty noob @ javascript , doing ict project. 'if' not work reason, button1 increase value of score.text one. highly appreciated. thanks!
change
var xx:number = 0; button1.addeventlistener(mouseevent.click, buttoncount); function buttoncount(event:mouseevent) { xx = xx +1; var xxx:string = string(xx); score.text = xxx } if (score.text == "1"){ feedback.text == "well done"; } to
var xx:number = 0; button1.addeventlistener(mouseevent.click, buttoncount); function buttoncount(event:mouseevent) { if (score.text == "1"){ feedback.text = "well done"; xx = xx +1; var xxx:string = string(xx); score.text = xxx }else{ feedback.text = "wrong." } } basically, changed feedback.text == "well done" feedback.text = "well done"
you use == in conditional statements, , if you're declaring text shall put =.
== means if equals, , = means if it's equalling, if if(blah=0) called if said blah = 0, though if said if(blah==0) call every time amount hits 0.
Comments
Post a Comment