Dictation Machine XML test
/**
* Copyright andrewexex886 ( http://wonderfl.net/user/andrewexex886 )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/z4d2
*/
package {
import flash.text.TextField;
import flash.display.Sprite;
public class FlashTest extends Sprite {
private var TF:TextField;
private var SelectedCourseName:Array;
private var SelectedCourseTotal:int;
private var VocabXML:XML;
private var VocabTotal:int;
//
private var vocalLibE:Array=[""];
private var vocalLibC:Array=["點Enter開始"];
private var vocalLibS:Array=[""];
public function FlashTest() {
TF = new TextField();
TF.width=TF.height=450;
TF.text = "loading";
addChild(TF);
///XML to Array
SelectedCourseName=["long_term_vision","ccc"];
SelectedCourseTotal=SelectedCourseName.length;
VocabXML=
<VocabularyLibrary>
<Vocabulary>
<Course>long_term_vision</Course>
<Eng>struggle</Eng>
<Chi>艱難</Chi>
<Sou>http://www.gstatic.com/dictionary/static/sounds/lf/0/s/st/str/struggle%23_gb_1.mp3</Sou>
</Vocabulary>
<Vocabulary>
<Course>bbb</Course>
<Eng>ultimate</Eng>
<Chi>極限的</Chi>
<Sou>http://www.gstatic.com/dictionary/static/sounds/lf/0/u/ul/ult/ultimate%23_gb_1.mp3</Sou>
</Vocabulary>
<Vocabulary>
<Course>ccc</Course>
<Eng>patience</Eng>
<Chi>恆心</Chi>
<Sou>http://www.gstatic.com/dictionary/static/sounds/lf/0/p/pa/pat/patience%23_gb_1.mp3</Sou>
</Vocabulary>
<Vocabulary>
<Course>long_term_vision</Course>
<Eng>renowned</Eng>
<Chi>有名的</Chi>
<Sou>http://www.gstatic.com/dictionary/static/sounds/lf/0/r/re/ren/renowned%23_gb_1.mp3</Sou>
</Vocabulary>
</VocabularyLibrary>;
VocabTotal=VocabXML.Vocabulary.length();
TF.text="";
var k:int=0;
for(k=0;k<VocabTotal;k++){
if(check_Selected_Course(VocabXML.Vocabulary.Course[k])){
vocalLibE.push(VocabXML.Vocabulary.Eng[k]);
vocalLibC.push(VocabXML.Vocabulary.Chi[k]);
vocalLibS.push(VocabXML.Vocabulary.Sou[k]);
}
}
TF.appendText(String(vocalLibE)+"\n"+String(vocalLibC)+"\n"+String(vocalLibS));
}
private function check_Selected_Course(incourse:String):Boolean{
var i:int=0;
while(i<SelectedCourseTotal){
if(incourse==SelectedCourseName[i]){
return true;
}
i++;
}
return false;
}
}
}