获取txt里面的内容


package com{

    import flash.net.URLLoader;
    import flash.net.URLRequest;
    import flash.events.Event;
    import flash.display.MovieClip;

    public class ReadTxt {

        private var txtLoad:URLLoader;
        private var txtURL:URLRequest;
        private var jumpBtn:MovieClip;
        public function ReadTxt(_jumpBtn:MovieClip) {
            jumpBtn=_jumpBtn;
            txtLoad = new URLLoader();
            txtURL=new URLRequest("txt.txt");
            txtLoad.addEventListener(Event.COMPLETE, showContent);
            txtLoad.load(txtURL);

        }
        private function showContent(evt:Event):void {
            trace(evt.target.data);
            var str:String=evt.target.data;
            if (str=="1") {
                jumpBtn.visible=true;
            } else {
                jumpBtn.visible=false;
            }
        }
    }

}

 

import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.events.Event;

var txtLoad:URLLoader = new URLLoader();
//txt.txt文本以UTF-8的编码保存。
var txtURL:URLRequest = new URLRequest("txt.txt");
txtLoad.addEventListener(Event.COMPLETE, showContent);
txtLoad.load(txtURL);
function showContent(evt:Event):void{
    TT.text = evt.target.data;
}

 

posted on 2018-06-12 14:04  zqiang0803  阅读(325)  评论(0编辑  收藏  举报

导航