kookaburra
January 30th, 2009, 01:59 AM
I'm working on test.fla, with document class test.as.
I write the following code to test.as
package {
import flash.display.MovieClip;
import flash.events.*;
import flash.utils.getTimer;
//Other Main Timeline imports go here! Don't forget!
public class test extends MovieClip {
public function test() {
this.loaderInfo.addEventListener(Event.INIT, initLoading);
this.loaderInfo.addEventListener(Event.COMPLETE, initApplication);
this.loaderInfo.addEventListener(ProgressEvent.PRO GRESS, showProgress);
}
public function initLoading(e:Event){
trace(Event.INIT+getTimer());
}
public function showProgress(theProgress:ProgressEvent):void {
var percent:Number = Math.round((theProgress.bytesLoaded / theProgress.bytesTotal )*100 );
trace(percent + " %");
this.graphics.clear();
this.graphics.lineStyle(1, 0x000000, 1);
this.graphics.beginFill(0x000000);
this.graphics.drawRect(100,100,percent,10);
}
public function initApplication(myEvent:Event):void {
trace("Loaded !"+flash.utils.getTimer());
}
}
}
The output is as follows:
init339
100 %
Loaded !341
Now my problem is the INIT event is fired at 339 milliseconds.
I need to show a preloader for the first 339 milliseconds.
Can someone help me?
I write the following code to test.as
package {
import flash.display.MovieClip;
import flash.events.*;
import flash.utils.getTimer;
//Other Main Timeline imports go here! Don't forget!
public class test extends MovieClip {
public function test() {
this.loaderInfo.addEventListener(Event.INIT, initLoading);
this.loaderInfo.addEventListener(Event.COMPLETE, initApplication);
this.loaderInfo.addEventListener(ProgressEvent.PRO GRESS, showProgress);
}
public function initLoading(e:Event){
trace(Event.INIT+getTimer());
}
public function showProgress(theProgress:ProgressEvent):void {
var percent:Number = Math.round((theProgress.bytesLoaded / theProgress.bytesTotal )*100 );
trace(percent + " %");
this.graphics.clear();
this.graphics.lineStyle(1, 0x000000, 1);
this.graphics.beginFill(0x000000);
this.graphics.drawRect(100,100,percent,10);
}
public function initApplication(myEvent:Event):void {
trace("Loaded !"+flash.utils.getTimer());
}
}
}
The output is as follows:
init339
100 %
Loaded !341
Now my problem is the INIT event is fired at 339 milliseconds.
I need to show a preloader for the first 339 milliseconds.
Can someone help me?