View Full Version : Site Preloading method/solution?
jarmanje
01-21-2008, 01:23 PM
Hello, I have a medium sized website which has a 300kb .swf in size
However a lot of my images are loaded dynamically from my database
I want to make one section of the dynamic loading not dynamic anymore, so i will put in the 30 thumbnail sized pictures into flash and deal with them from within flash instead of loading them (e.g. load /images/pic1.jpg)
These are my problems/questions:
1)
When i first load my website, it shows a black screen for about 5-10 seconds before it plays my very very short intro movie (the logo moves).
How can i get rid of this horrible blackness before it starts? Is there an easy way to preload the main timeline with a bar and then it shows the mini intro and goes into the main site. I am pretty handy with flash, but never really used preloading much!! Mainly i preload a single external image or something
2)
This section within the site (an internal movie clip) which i want to make not dynamically load the images, just place images within the flash. I dont want to load or preload this until the user clicks on this section. So I dont want it to be included in the main preloading of the time line.
how would i go about this?
Thanks so much for any help / links / snippets! Really appreciate the help on these forums
jarmanje
01-22-2008, 08:15 AM
raise post
MikeTheVike
01-22-2008, 06:38 PM
this is a very basic preloader...
stick it on the first frame, and all the rest of your stuff on frames after...
stop();
//Preloader Action Script
loaderInfo.addEventListener (ProgressEvent.PROGRESS, plLoading);
function plLoading(event:ProgressEvent) :void {
var pcent:int=event.bytesLoaded/event.bytesTotal*100;
//loadbar_mc is the name of the load bar movie clip instance
loadbar_mc.scaleX=pcent/100;
//percentDone_dtext is the name of the dynamic text box that
//displays the percentage
percentDone_dtext.text=String(pcent) + "%";
if(pcent==100) {
gotoAndPlay(2);
}
}
as for the other question, you could just use addChild(movieclip) after loading an external movie.
jarmanje
01-23-2008, 06:24 PM
but this doesnt work with AS3
everything is loaded into Frame 1 of the movie, so you end up with a black screen THEN the preloader shows for a split second...
I also tried loading the main swf into another one and preloading it like that, which does work. But i encounter many many errors because it can't load components etc from the internal swf..
this is annoying, i just want to simply preload my main timeline AS2 style in AS3
Dolfan23
01-23-2008, 06:34 PM
Why not create a loading movie that would only be 1kb and have 2 loaders for it, one that loads an intro swf (for your logo) and the other that loads your main swf. Once the intro swf has completed loading then start your main swf loading and have a message on screen saying that it's loading or whatever.
jarmanje
01-23-2008, 08:07 PM
I tried that, but my when i load my main.swf into the small 1kb swf, it get lots of errors running it. it cannot load components etc etc
its quite a complex main swf...
jarmanje
05-24-2008, 04:19 PM
Has anybody found a solution to a complex swf preloading?
mine still has a black screen on the first load before the preloader shows up..
stompwampa
05-25-2008, 02:24 AM
there's no reason that your loader swf should cause problems with the swf it is loading. As long as the swf it is loading has all the components and whatnot working correctly, it should function just fine regardless of what is loading it...
post the code you're using to preload your movie.
lordofduct
05-25-2008, 02:50 AM
I don't usually keep much inside of the swf itself unless it is really necessary. Things like vector art and the sort will be in my swf. The rest of my stuff is outside of the swf and loaded in by the program.
This way I have very little to load up before I can do anything. Then once that is done I start up my loading video (something like a spinning wheel or something). I let this play while I load in all data I need. Like sound, jpegs, other stuff. Once that is all loaded I build my scene, finally once it's all built I stop the loading movie, dispose of the loading movie, and make the scene visible.
Downside is this isn't really effective if your swf has a ton of stuff in it that just can't be taken out of it (i.e. tons and tons of vector art). In this scenario I don't really have any effective methods for dealing with this. Some suggestions:
store everything in an external swf which you load. This swf doesn't really act as a scene, but instead just contains a library of items you can make copies of for your scene. Downside this means you have to construct your scene in code.
Another way could be creating a basic swf that only handled loading. This swf loaded up your actual website and then once it was loaded it stops its loading movie and makes the loaded swf a child of its display list. Downside to this is you have to keep in mind this is being done when you code your website. You can't be referencing the root and the stage the same way. The stage isn't quite what you think anymore seeing you have one swf inside another.
jarmanje
05-25-2008, 03:10 PM
I don't usually keep much inside of the swf itself unless it is really necessary. Things like vector art and the sort will be in my swf. The rest of my stuff is outside of the swf and loaded in by the program.
This way I have very little to load up before I can do anything. Then once that is done I start up my loading video (something like a spinning wheel or something). I let this play while I load in all data I need. Like sound, jpegs, other stuff. Once that is all loaded I build my scene, finally once it's all built I stop the loading movie, dispose of the loading movie, and make the scene visible.
Downside is this isn't really effective if your swf has a ton of stuff in it that just can't be taken out of it (i.e. tons and tons of vector art). In this scenario I don't really have any effective methods for dealing with this. Some suggestions:
store everything in an external swf which you load. This swf doesn't really act as a scene, but instead just contains a library of items you can make copies of for your scene. Downside this means you have to construct your scene in code.
Another way could be creating a basic swf that only handled loading. This swf loaded up your actual website and then once it was loaded it stops its loading movie and makes the loaded swf a child of its display list. Downside to this is you have to keep in mind this is being done when you code your website. You can't be referencing the root and the stage the same way. The stage isn't quite what you think anymore seeing you have one swf inside another.
Thanks a lot for your useful comments. i completley agree with everything you say. My main problem is, I am quite handy with cs3 now. But i wasn't when i started. My application is actually pretty complex now, and the swf is about 350k with mbs and mbs of external images being loaded. I suppose I will just try to cut it down to an absolute minimum of images inside the actual swf.
I use make my rollover buttons with a mc, but perhaps I should load them all in externally. That might take off another 100k or so...
I should of made the thing using flex! I have lots of components and data usage :( Another learning curve
lordofduct
05-25-2008, 04:43 PM
oh you have all this code written on the timeline?
Yeah my suggestion would be to pull it all out and write up a series of classes to deal with everything. Then you could handle all the images on their own and pass them around to everything as needed. I've rarely used the timeline except to just test short snippets of code, using classes or flex make organizing so much easier. It takes a while, I'm still hardly any good at organizing my code, but it pays in the end.
|
vBulletin® v3.8.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.