I want to load an external text file, and display loading percentage in flash,so I could show user how far loading is completed.
And the problem is I can see progress in trace window,no progross message displays in the textfield,only when my text is completly loaded,the whole text shows in flash.
code:
var mytxt_txt:TextField=new TextField();
mytxt_txt.x=10;
mytxt_txt.y=10;
mytxt_txt.width=400;
mytxt_txt.height=300;
mytxt_txt.multiline = true;
mytxt_txt.wordWrap = true;
mytxt_txt.border = true;
addChild(mytxt_txt);
//
var _txtloader:URLLoader = new URLLoader();
_txtloader.addEventListener(Event.COMPLETE, completeHandler);
_txtloader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
_txtloader.load(new URLRequest(“test.txt”));
//
function progressHandler(evt:ProgressEvent):void {
var _percent:Number=0;
_percent=Math.round(evt.bytesLoaded/evt.bytesTotal*100);
trace(evt.bytesLoaded);
trace(evt.bytesTotal);
trace(_percent+"%");
trace("--------------------");
mytxt_txt.text=_percent.toString();
}
//
function completeHandler(evt:Event):void {
mytxt_txt.text=_txtloader.data;
}
simulate download and in the trace windows:
65536
529995
12%
131072
529995
25%
196608
529995
37%
262144
529995
49%
327680
529995
62%
393216
529995
74%
458752
529995
87%
524288
529995
99%
529995
529995
100%
Anybody have an idea why?