Jedisloth
November 12th, 2009, 05:03 PM
Hi!
Im currently getting my flash portfolio ready to go live. everything works fine except its slow....now this is not my pc if you were wondering, but everytime i click a link that opens a new swf (addChild) it takes 1 or 2 second before it starts loading (This happens only online). Fine the preloader also has to load but the preloader is only a bar and percentage that shows, nothing fancy so that shouldnt be a problem.
Does anyone have an idea why this might be?
Here is the code i used for my preloader:
stop();
import flash.display.*;
var tb:Number; // total bytes
var lb:Number; // loaded bytes
var pd:int; // percent done
// add an ENTER_FRAME event listener to the current timeline
this.addEventListener(Event.ENTER_FRAME, onStageEnter);
function onStageEnter(event:Event):void
{
// if the movie is not fully loaded
// then keep on loading data and updating "percent done"
if(this.pd != 100)
{
this.tb = this.loaderInfo.bytesTotal;
this.lb = this.loaderInfo.bytesLoaded;
// calculate pd ( percent done )
this.pd = int((this.lb / this.tb) * 100);
// scales loading bar
loadBar.scaleX=pd/100;
// display the current pd in pd_field text field
textMC.textBox.text = String(this.pd + "%");
// moves the text along with the loading bar
textMC.x= (pd*2.3) + 339.6;
}
// ...once the movie has completed loading
else
{
// do something - go and stop at frame 2
this.gotoAndPlay(2);
// remove the ENTER_FRAME event listener
this.removeEventListener(Event.ENTER_FRAME, onStageEnter);
}
} // end of onStageEnter
// stop your movie from playing
this.stop();
And this is the code i use to call my swf:
portfolio_btn.addEventListener(MouseEvent.CLICK, openPorfolio);
function openPorfolio(event:MouseEvent) {
var portfolio:Loader = new Loader();
var portfolioURL:URLRequest = new URLRequest("Swf/Portfolio.swf");
portfolio.load(portfolioURL);
stage.addChild(portfolio);
}
Now please be gentle im still very much a noob at AS3 coding. Im a designer ^-^ not a developer....well not yet! :lol:
Thanks in advance!
:beam:
Im currently getting my flash portfolio ready to go live. everything works fine except its slow....now this is not my pc if you were wondering, but everytime i click a link that opens a new swf (addChild) it takes 1 or 2 second before it starts loading (This happens only online). Fine the preloader also has to load but the preloader is only a bar and percentage that shows, nothing fancy so that shouldnt be a problem.
Does anyone have an idea why this might be?
Here is the code i used for my preloader:
stop();
import flash.display.*;
var tb:Number; // total bytes
var lb:Number; // loaded bytes
var pd:int; // percent done
// add an ENTER_FRAME event listener to the current timeline
this.addEventListener(Event.ENTER_FRAME, onStageEnter);
function onStageEnter(event:Event):void
{
// if the movie is not fully loaded
// then keep on loading data and updating "percent done"
if(this.pd != 100)
{
this.tb = this.loaderInfo.bytesTotal;
this.lb = this.loaderInfo.bytesLoaded;
// calculate pd ( percent done )
this.pd = int((this.lb / this.tb) * 100);
// scales loading bar
loadBar.scaleX=pd/100;
// display the current pd in pd_field text field
textMC.textBox.text = String(this.pd + "%");
// moves the text along with the loading bar
textMC.x= (pd*2.3) + 339.6;
}
// ...once the movie has completed loading
else
{
// do something - go and stop at frame 2
this.gotoAndPlay(2);
// remove the ENTER_FRAME event listener
this.removeEventListener(Event.ENTER_FRAME, onStageEnter);
}
} // end of onStageEnter
// stop your movie from playing
this.stop();
And this is the code i use to call my swf:
portfolio_btn.addEventListener(MouseEvent.CLICK, openPorfolio);
function openPorfolio(event:MouseEvent) {
var portfolio:Loader = new Loader();
var portfolioURL:URLRequest = new URLRequest("Swf/Portfolio.swf");
portfolio.load(portfolioURL);
stage.addChild(portfolio);
}
Now please be gentle im still very much a noob at AS3 coding. Im a designer ^-^ not a developer....well not yet! :lol:
Thanks in advance!
:beam: