In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Dictation Machine Alpha

Get Adobe Flash player
by andrewexex886 11 Sep 2011
    Embed
/**
 * Copyright andrewexex886 ( http://wonderfl.net/user/andrewexex886 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/pLzk
 */

/**
 * Copyright andrewexex886 ( http://wonderfl.net/user/andrewexex886 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/2LoR
 */

package {
    import flash.net.URLRequest;
    import flash.media.Sound;
    import flash.text.TextFormat;
    import flash.display.Stage;
    import flash.events.Event;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.text.TextFieldType;
    import flash.display.Sprite;
    import flash.ui.Keyboard;
    public class FlashTest extends Sprite {
        private var butt:Sprite;
        private var tf:TextField;
        private var tf2:TextField;
        private var vocalLibE:Array=[""];
        private var vocalLibC:Array=["點Enter開始"];
        private var vocalLibS:Array=[""];
        private var vocalLibLenght:int;
        private var nowVocalNum:int=0;
        private var fStage:Stage;
        private var mySound:Sound = new Sound();
        public function FlashTest() {
                fStage=stage;
                //vocal Library
                    //2011-07-22
               var vocalLibE_long_term_vision:Array=["struggle","ultimate","patience","renowned","buddhist","philosopher","author","obstacle","operatic","constant","doubt","confidence","capabilities","temporarily","instead","concentrated","exceptional","failures","timid","depend"];
               var vocalLibC_long_term_vision:Array=["艱難","極限的","恆心","有名的","佛教徒","哲學家","作者","障礙","歌劇的","常數","不確定","舒適的","才能","暫時地","代替","決心要做的","優秀的","失敗者","膽怯的","依靠"];
               var vocalLibS_long_term_vision:Array=["http://www.gstatic.com/dictionary/static/sounds/lf/0/s/st/str/struggle%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/u/ul/ult/ultimate%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/p/pa/pat/patience%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/r/re/ren/renowned%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/!Buddhist.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/p/ph/phi/philosopher%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/a/au/aut/author%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/o/ob/obs/obstacle%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/operatic.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/x/xc/xco/xconstant%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/d/do/dou/doubt%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/x/xc/xco/xconfidence%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/capability.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/temporarily.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/i/in/ins/instead%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/x/xc/xco/xconcentrated%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/e/ex/exc/exceptional%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/failure.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/t/ti/tim/timid%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/d/de/dep/depend%23_gb_1.mp3"];
               vocalLibE = vocalLibE.concat(vocalLibE_long_term_vision);
               vocalLibC = vocalLibC.concat(vocalLibC_long_term_vision);
               vocalLibS = vocalLibS.concat(vocalLibS_long_term_vision);
                    //2011-07-25Anthropology
               var vocalLibE_Anthropology:Array=["anthropology","anthropologist","mongolia","fieldwork","benefit","assimilation","gradually","herd","yak","peak","shield","wrist","dangle","moustache","lip"];
               var vocalLibC_Anthropology:Array=["人類學","人類學家","蒙古","實地考察","益處","吸收","逐漸地","放牧","牦牛","山峰","保護","手腕","晁來晁去","鬍子","唇"];
               var vocalLibS_Anthropology:Array=["http://www.gstatic.com/dictionary/static/sounds/lf/0/a/an/ant/anthropology%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/a/an/ant/anthropologist%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/!Mongolia.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/f/fi/fie/fieldwork%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/b/be/ben/benefit%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/assimilation.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/g/gr/gra/gradually%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/herd.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/y/ya/yak/yak%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/p/pe/pea/peak%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/shield.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/w/wr/wri/wrist%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/dangle.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/m/mo/mou/moustache%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/l/li/lip/lip%23_gb_1.mp3"];
               vocalLibE = vocalLibE.concat(vocalLibE_Anthropology);
               vocalLibC = vocalLibC.concat(vocalLibC_Anthropology);
               vocalLibS = vocalLibS.concat(vocalLibS_Anthropology);
                    //2011-07-25 Ashes
               var vocalLibE_Ashes:Array=["ash","indifferent","incredibly","compassionate","enormous","helicopter","scattering","meadow","ridden","pony","weeping","fleck"];
               var vocalLibC_Ashes:Array=["骨灰","漠不關心","難以置信地","有同情心","巨大的","直昇機","散落","牧場","騎馬","小馬","落淚","微粒"];               
               var vocalLibS_Ashes:Array=["http://www.gstatic.com/dictionary/static/sounds/lf/0/a/as/ash/ash%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/i/in/ind/indifferent%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/i/in/inc/incredibly%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/c/co/com/compassionate%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/e/en/eno/enormous%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/h/he/hel/helicopter%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/de/0/scattering.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/m/me/mea/meadow%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/r/ri/rid/ridden%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/p/po/pon/pony%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/w/we/wee/weeping%23_gb_1.mp3","http://www.gstatic.com/dictionary/static/sounds/lf/0/f/fl/fle/fleck%23_gb_1.mp3"];
               vocalLibE = vocalLibE.concat(vocalLibE_Ashes);
               vocalLibC = vocalLibC.concat(vocalLibC_Ashes);
               vocalLibS = vocalLibS.concat(vocalLibS_Ashes);
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                
                //set Length
                vocalLibLenght=vocalLibE.length;
                //setup textField                      
                tf = new TextField();
                this.addChild(tf);
                tf.type=TextFieldType.INPUT;
                tf.border=true;
                tf.y=50;
                tf.width=200;
                tf.height=40;
                tf2 = new TextField;
                tf2.text=vocalLibC[0];
                tf2.selectable=false;
                tf2.width=200;
                tf2.height=40;
                this.addChild(tf2);
                var txtF:TextFormat= new TextFormat("Arial",30);
                //tf.defaultTextFormat=txtF;   
                tf.defaultTextFormat=txtF;
                tf2.defaultTextFormat=txtF;
                tf2.setTextFormat(txtF);
                //Button
                butt=new Sprite();
                butt.graphics.beginFill(0,1);;
                butt.graphics.drawRect(0,0,50,50);
                butt.graphics.endFill();
                butt.x=300;
                butt.buttonMode=true;
                addChild(butt);
                butt.addEventListener(MouseEvent.CLICK,postAnsButt);
                stage.addEventListener(KeyboardEvent.KEY_DOWN,postAnsKeyboard);
        }
        private function postAnsButt(E:MouseEvent=null):void{
            if(checkAnswer(tf.text)){
                //randomGetVocal();
                orderGetVocal();
            }else{
                tf2.appendText("X");
                }
            tf.text="";
            mySound.play();            
        }
        private function postAnsKeyboard(E:KeyboardEvent=null):void{
            if(E.keyCode==Keyboard.ENTER){
                postAnsButt();
            }

        }
        private function randomGetVocal():void{
            nowVocalNum=Math.round(Math.random() * (vocalLibLenght-1));
            tf2.text=vocalLibC[nowVocalNum];
        }
        private function orderGetVocal():void{
            if(nowVocalNum>=(vocalLibLenght-1)){
                nowVocalNum=0;
            }else{
            nowVocalNum++;
            }
            tf2.text=vocalLibC[nowVocalNum];
            playmp3(vocalLibS[nowVocalNum]);
        }
        private function checkAnswer(ans:String):Boolean{
            if(ans==vocalLibE[nowVocalNum]){
                return true;
            }
            return false;
        }
        private function playmp3(mp3url:String=null):void{
            mySound = new Sound();
            var request:URLRequest = new URLRequest(mp3url);
            mySound.addEventListener(Event.ID3, Id3Handler);
            mySound.load(request);
            mySound.play();
        }
        private function Id3Handler(event:Event):void {
            trace(String("歌曲ID3信息:"+mySound.id3.artist));
        }
    }
}