PDA

View Full Version : Slow Loading Swf's



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:

cjke.7777
November 13th, 2009, 04:59 AM
Is the preloader part of the main swf file? Once the main swf has loaded, links within that load other swfs, is this right?

Jedisloth
November 13th, 2009, 05:34 AM
yes thats right, but each swf has the same kind of preloader in them as well, since they need to load other content like pictures which is my portfolio work etc.

idk maybe its the code interferring or getting a bit to much, but i doubt it. its not giving me any errors its just delayed when loading.

cjke.7777
November 13th, 2009, 06:27 AM
is the preloader within the sub page swf for the content they load, or for themselves?

I'd have a preloader in the main swf that shows the loading of each sub page, because at the moment i'd say the delay is because the sub page hasn't loaded what so ever.

Jedisloth
November 18th, 2009, 03:54 AM
see it works like this....

Home.swf:
Frame 1)Preloader
Frame 2+)Rest of the timeline (contains links to other swf's like Portfolio.swf)

Portfolio.swf:
Frame 1)Preloader
Frame 2+)Rest of the timeline blah blah blah

you get the drift :)

i do understand the preloader has to load itself and if i understand correct the are other properties loaded that flash automatically loads that it needs. but this delay is much longer than that would be i think.

So what you say is i must have this one global preloader that gets used over and over again each time new swf is loaded? and if so how do i do that?

:D

Remember to smile today :D

Jedisloth
December 11th, 2009, 01:22 PM
here is the link to the site if you want to check it out yourself...

www.thumbsupdesign.co.za/Flashsite.html

Hope somebody can help me!
Thank you