Answer the question
In order to leave comments, you need to log in
Why does the preloader not work on AS?
There is a preloader code.
stop();
var load_info:TextField = new TextField();
load_info.text = "Загрузка...";
load_info.x=318,95;
load_info.y=476,25;
addChild(load_info);
var tfNameFormat:TextFormat = new TextFormat();
tfNameFormat.size = 14;
tfNameFormat.color = 0xffffff;
load_info.setTextFormat(tfNameFormat);
addEventListener(Event.ENTER_FRAME, loadF);
function loadF(e:Event):void{
var TLoad:Number = loaderInfo.bytesTotal;
var loaded:Number = loaderInfo.bytesLoaded;
var total:Number = loaded/TLoad;
if(loaded == TLoad){
removeEventListener(Event.ENTER_FRAME, loadF);
} else {
load_info.text = Math.floor(total*100) + " %";
addChild(load_info);
}
}
load_info.text = Math.floor(total*100) + " %";
addChild(load_info);
Answer the question
In order to leave comments, you need to log in
why addChild(load_info); in handler? this code fires every frame
needs to be traced
stop();
var load_info:TextField = new TextField();
load_info.text = "Загрузка...";
load_info.x=318,95; //зачем дробные части?
load_info.y=476,25; //зачем дробные части?
var tfNameFormat:TextFormat = new TextFormat();
tfNameFormat.size = 14;
tfNameFormat.color = 0xffffff;
load_info.setTextFormat(tfNameFormat);
addChild(load_info);
addEventListener(Event.ENTER_FRAME, loadF);
function loadF(e:Event):void{
var TLoad:Number = loaderInfo.bytesTotal;
var loaded:Number = loaderInfo.bytesLoaded;
var total:Number = loaded/TLoad;
if (loaded == TLoad) {
removeEventListener(Event.ENTER_FRAME, loadF);
} else {
load_info.text = Math.floor(total*100) + " %";
trace(load_info.text, (Math.floor(total*100) + " %"))
}
}
If this code is in the preloader itself, which is like a separate class, then it is already loaded and its loaderInfo is already 100% in place.
Also, you need to check if the textField is not static. If it was put in Flash IDE, then it has a drop-down list in its properties in which you need to select dynamic text
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question