In a small learning game, students must click on the proper button, representing a name of an element:
[COLOR=magenta]on (release){[/COLOR]
[COLOR=magenta]searchElement(“O”,no=11); [/COLOR][COLOR=dimgray]// searches for Oxigen[/COLOR]
[COLOR=magenta]}[/COLOR]
[COLOR=magenta]on (release){[/COLOR]
[COLOR=magenta]searchElement(“H”,no=10); [/COLOR][COLOR=dimgray]// searches for Hydroxide[/COLOR]
[COLOR=magenta]}[/COLOR]
The names of the elements for that particular question, flash finds in an array:
[COLOR=magenta]mcFormula.elementsArray = [“H”,“O”];[/COLOR]
Things come together in this function:
[COLOR=magenta]function searchElement(elementName,no){[/COLOR]
[COLOR=magenta]for(var i:String in mcFormula.elementsArray){[/COLOR]
[COLOR=magenta]if (mcFormula.elementsArray* == elementName){[/COLOR]
[COLOR=magenta]root["mcCheck"+ no].gotoAndStop(2);[/COLOR][COLOR=dimgray] // shows Ok. sign[/COLOR]
[COLOR=magenta]}else{[/COLOR]
[COLOR=magenta]root["mcCheck"+ no].gotoAndStop(3); [/COLOR][COLOR=dimgray]// shows Not Ok sign[/COLOR]
[COLOR=magenta]} [/COLOR]
[COLOR=magenta]trace(mcFormula.elementsArray* + " = " + elementName); [/COLOR][COLOR=dimgray]//shows my good work…[/COLOR]
[COLOR=magenta]}[/COLOR]
[COLOR=magenta]}[/COLOR]
It only works on the first item: “H”. The “O” will not be found, however trace shows me I’ve done things well.
Can anyone tell me the reason for this?
I’ve been looking the whole day at these few sentences, without result.