PDA

View Full Version : Preloading a Scene at a time?


bryce
12-13-2006, 07:23 PM
So the site i'm working on is an online portfolio and is about 19mb. Apart from resizing and lowering quality (to reduce file size and thus loading time) I'm looking for a way to preload the site a scene at a time as it is navigated through, as opposed to preloading the entire site at once which takes way too long. Currently the code I'm using to preload the enitre site is:

preloader.preloader_bar._xscale = 0;
preloader._visible = false;
stop();

function startMovie() {
if ((getBytesLoaded() == getBytesTotal())) {
preloader._visible = false;
gotoAndPlay("start");
} else {
startLoad(this);
}
}

assessLoad = function (Clip, endPreLoad) {
var kbLoaded:Number = Clip.getBytesLoaded()/1024;
var kbTotal:Number = Clip.getBytesTotal()/1024;
var percent:Number = Math.floor(kbLoaded/kbTotal*100);
preloader.preloader_bar._xscale = percent;
preloader.pct_loaded.htmlText = percent+"%";
if ((kbLoaded/kbTotal == 1) && kbLoaded>1) {
endPreLoad();
}
}

endPreload = function () {
clearInterval(preload);
gotoAndPlay("start");
}

function startLoad(Clip) {
preload = setInterval(assessLoad, 100, Clip, endPreload);
preloader._visible = true;
preloader.preloader_bar._xscale = 0;
}

startMovie();



Is there a way I can get this to only load one scene instead of the entire site? Also, I have read in various places that scenes are to be avoided, so If I didn't break each section of the site into scenes, how then could I go about preloading the different sections as they are selected, as opposed to having the entire movie clip preload?

CyanBlue
12-13-2006, 07:29 PM
Howdy and Welcome... :)

I've got to admit that I have not read your code...
The reason why I am replying is to tell you how Flash creates SWF file...

Let's say that you have 3 scenes in your FLA each are 100 frames long...
When you publish the SWF, Flash automatically creates 300 frames long SWF file which does not have any distinction on the scene... The starting frame of scene 2 will be located in frame 101 and so on...
So, there is no way you can load one scene because such thing does not exist in the SWF file anymore...
If you really need to load the section, you will need to create multiple SWF files for each scenes... Know what I mean??? ;)

bryce
12-13-2006, 07:34 PM
Thanks, that makes alot of sense. Just to continue proving that I am a newbie, I have another question; How do I get a navigational button to send the navigator to the other swf file that contains that section of work? Would I have to create different html documents in dreamweaver each containing the different swf files and then have the button send it to the url...yeah I think i just figured it out...but If i'm wrong let me know...thanks again!

CyanBlue
12-13-2006, 07:38 PM
If you need to load an external SWF file, you will have to use loadMovie("file.swf"); command to do that... ;)

bryce
12-13-2006, 07:53 PM
Thanks!

CyanBlue
12-13-2006, 07:59 PM
You're welcome... :)

bryce
12-13-2006, 08:16 PM
Sorry, now I thought of another question. Can I have a button load an external swf file but have it go to a certain frame of that swf without loading the swf at the beginning? Or is that not possible? Also, when exporting and previewing this process I saw that the screen flashes white in between the swf files, is there any way to have the process of transition from swf to swf occur without this white screen? or is that what php is all about...

CyanBlue
12-13-2006, 08:20 PM
Well... I am not saying I don't want to help you, but you are moving from one topic to another which is not good for somebody who come across to this thread because they have the same problem... I sugges you create a new thread and also do the search on the forum because I've seen many threads of the similar/same questions asked before... ;)

bryce
12-13-2006, 08:28 PM
Thanks, and sorry about that.

CyanBlue
12-13-2006, 08:30 PM
Not a problem... ;)