|
-
[F8] Preloader for PARTS of file
I know there are a million preloader threads but I couldn't find the answer to this. I have a preloader but I want it to only look at part of my file, whereas currently it is waiting for the whole thing to load. Because I have some large images to load I want them to be ignored and they can collectively have their own preloaders once the user gets to that point. How do I do this? Here's the code:
totalBytes = this.getBytesTotal();
loadedBytes = this.getBytesLoaded();
remainingBytes = totalBytes - loadedBytes
percentDone = int((loadedBytes/totalBytes)*100);
bar.gotoAndStop(percentDone);
if (_framesloaded == _totalframes) {
gotoAndPlay(3);
}
Thanks in advance...
-
Senior Member
HI.. to address your question(s).. itreally pertains to the logic of how you build your site...and how 'preloader code' works.
Overall logic, a .swf has to load a certain percentage of itself..before ANY OF IT can be displayed on the stage. This is why you see many advanced memebers recommend NOT putting preloaders IN the same .swf you are trying to 'preload' (make sense?)
Most of the time, flash web sites are built to load their (external) content INTO a main.swf (usually the index or main.swf that has logo, navigation, graphics.etc..and a spot to load the content to be viewed).. this is done my loading either .swf's, images, videos...etc into targetClips, often referred to as containerClips, these are nothing more than blank/empty movieClips on the stage.. (with an instance name) that sits, waiting to have stuff loaded into them.
When done loading content (correctly) as above..you can THEN.. have your 'preloader code' 'watch' these containerClips... and tell you how much of the content you are loading into it is currently loaded. (make sense?)
NOW..to apply this logic to your project.
If you want to have a preloader look at only a portion of yoru site..then you need to separate it somehow, so it can be loaded, and checked to see its current status...
I suggest you either:
a.) put all the images in separate .swf and load the whole external.swf into the current .swf when they want to view the gallery.. and you can put a preloader to wait and display the whoel ting loading..
or
b.) just load each image individually, and one at a time, having the preloader 'trigger/display' each time a new image is being loaded.
-
Alright, as in many cases here on this board your logic makes sense but I don't quite get how to actually implement these things. Let's start with the first section:
You mention that a .swf has to load a certain percentage of itself before any of it can be displayed. Okay, that makes sense, so this would cause the movie used for the preloader to not appear right off. Got it. So can I make an .swf that only has the preloader image and code that then loads my entire main .swf (which includes all sorts of various movie clips, layouts, images etc.)? How would I change my code (above) to look at what's being loaded externally, then?
Onto the next part:
I suggest you either:
a.) put all the images in separate .swf and load the whole external.swf into the current .swf when they want to view the gallery.. and you can put a preloader to wait and display the whoel ting loading..
Okay, so currently I have several images that are each individually loaded by the click of a thumbnail, so how do I organize these in the said external.swf so they appear in the proper frame/empty movie clips when loaded? And how do I have this preloader look at this specific .swf once the user enters the first frame of the gallery section? 
Thanks for your help!
-
Senior Member
I think you need to forget about preloaders for a moment.... and learn how to just loadd in dynamic content.
create a new .swf make a button..(button1)
make a blank/empty movieClip on the stage.. call it (containerClip)
now this code:
button1.onPress = function(){
containerClip.loadMovie("image1.jpg");
}
You saw you understand the logic.. but I don think you do... or you would be asking how to:
how do I have this preloader look at this specific .swf
as stated above when explaining the logic of how loading works (no mention of preloaders)... you load into a TARGET!.. doesnt matter what gets loaded into it..you always 'watch' the targetClip.. not the external.swf the targetClip.. doesnt matter if you are loading .swf's, images, text, videos... you watch the TARGETCLIP....
You say you are loading these images in individually, by clicking a thumbnail..
HOW?
post the line of code that loads these images.
you have to be loading them into something.....right?..either a target or a _level
do you have different SCENES? if so.. I HIGHLY recommend never, ever, ever, ever using scenes.. they will only cause trouble in the end.
-
Well, you've definitely learned how little I know about all this. Somehow I've managed to almost finish a site out of my limited knowledge, but it does mean I run into some pretty serious barriers.
Now to the post- Okay, targetClips. (I probably should have said I understand the general idea over the logic.) So I can load just about anything into a targetclip- including a fairly elaborate .swf with many different mc's inside of it?
As for loading these images individually, I guess I should rephrase it. A thumbnail is clicked and...
on (release) {
_root.gotoAndStop("pga")
}
...it goes to a different frame which has the image already in it. Another movieClip, when pressed, goes to another frame which contains all new thumbnails, that when clicked go to a specific frame containing that image. It seems to work really well.
I'm not using scenes. Fortunately I came into this forum early enough to have been warned against them.
-
Senior Member
ok..your not too far off base then.. and I'll try to keep the curent logic you have/know and include the new stuff to get you where you need to b (nothign worse than using code you dont understand) 
ok.. the images are already imported to the stage and in a movieClip..that whena button is clicked..changes the frame of the movieClip..that has all the images inside fo it..correct? (actually it seemd the images of just on _root)
tip: I always try to wrap/contain things in their OWN movieClips... and here why:
1.) using the situation above.. all of the images are on the _root/main time line.. if they were all inside of a movieClip.. you could then move all images at once....as well as do things as a whole to all the images.. fade, alpha, positioning..etc..
2.) I never create websites, application..anything.. that are more than 1 frame long in my _root/main time line. this means, that no matter if I have 20 layers...with graphics...movieClips..etc.. nothign is more than 1 frame long.. now, in any one of these layers..there could be a movieClip.. and INSIDE that movieClip.. that timeline may be doing whatever it needs to do..100 frames long..tweens..etc.. but I can control this timeline form the MAIN timeline..
any timeline can basically talk/control another timeline..
so.. for you..
I would get rid of ALL the images you have in this .swf... and put them in another external.swf with as many graphics and eye candy as you like..
next..back in the MAIN.swf create/drag a blank movieClip to the stage.. position it where you want your images to show up.. give it instance name of containerClip.
(question:, are the thumbnail clips that change frames for images in the external.swf or in the MAIN.swf?
I knwo you say when you get to the gallery section..but how to do GET TO THE GALLERY section? You are NOT loading in an external.swf that is the gallery section are you??
well once you get to this point..you will..
so when the users go to gallery.. (or click gallery button..whatever)
you shoudl have this code:
on(press){
containerClip.loadMovie("exeternal.swf");
}
this will load the external.swf into the targetClip (called: containerClip)
now depending onw where your buttons are.. the code to change the frames/image will be like this:
not:
on (release) {
_root.gotoAndStop("pga")
}
but intead:
on (release) {
_root.containerClip.gotoAndStop("pga")
}
(if in the enxternal.swf you put all images on the _root timeline (not recommended) and give them all frame names.. if you put the images in a movieClip (name: imageHolder) on the main timeline in the external.swf it eould be like this:
on (release) {
_root.containerClip.imageHolder.gotoAndStop("pga")
}
tis is NOT preloader anything..ocne you get here..preloader is easy part.
-
 Originally Posted by whispers
ok..your not too far off base then.. and I'll try to keep the curent logic you have/know and include the new stuff to get you where you need to b (nothign worse than using code you dont understand) 
Yes- thanks for keeping it down to my level (no, really!)
ok.. the images are already imported to the stage and in a movieClip..that whena button is clicked..changes the frame of the movieClip..that has all the images inside fo it..correct? (actually it seemd the images of just on _root)
Correct. Yes, they are all on _root, though I do know how to do the same thing in its own movieclip. Based on your explanation I can see why I should do this and will make the change. My one question here is how to reference the frame inside the movieclip- I can still give the frame it's own unique name, but instead of starting with _root what prefix do I use?
so.. for you..
I would get rid of ALL the images you have in this .swf... and put them in another external.swf with as many graphics and eye candy as you like..
What about some vector shapes I have that are the basis for my layout. Shall I just leave these in the main .swf?
next..back in the MAIN.swf create/drag a blank movieClip to the stage.. position it where you want your images to show up.. give it instance name of containerClip.
(question:, are the thumbnail clips that change frames for images in the external.swf or in the MAIN.swf?
I knwo you say when you get to the gallery section..but how to do GET TO THE GALLERY section? You are NOT loading in an external.swf that is the gallery section are you??
No, it's simply another frame on the main timeline that people go to once they click the "gallery" link button. This and the next so many frames all have the same layout, but each individual frame has a different piece of art appearing at a given coordinate.
well once you get to this point..you will..
so when the users go to gallery.. (or click gallery button..whatever)
you shoudl have this code:
on(press){
containerClip.loadMovie("exeternal.swf");
}
this will load the external.swf into the targetClip (called: containerClip)
now depending onw where your buttons are.. the code to change the frames/image will be like this:
not:
on (release) {
_root.gotoAndStop("pga")
}
but intead:
on (release) {
_root.containerClip.gotoAndStop("pga")
}
(if in the enxternal.swf you put all images on the _root timeline (not recommended) and give them all frame names.. if you put the images in a movieClip (name: imageHolder) on the main timeline in the external.swf it eould be like this:
on (release) {
_root.containerClip.imageHolder.gotoAndStop("pga")
}
tis is NOT preloader anything..ocne you get here..preloader is easy part.
Okay, this seems to make sense. You're giving me two options- one using my existing "root timeline" method and the other using movieClips. Got it. For my gallery section all the various jpegs are being placed in the same top left x/y coordinates, so they can all go to the same targetClip. What I don't get is, do I have to use a seperate external .swf for every location I want graphics (or mc's) to appear, or is there a way to pull in just the desired graphics/mc's from an external file that contains multiple graphics/mc's, and if so, how do I arrange them within that external .swf?
Thanks for your time. I very much appreciate your help.
Last edited by progfellow; 05-09-2007 at 02:34 PM.
Reason: legibility
-
Senior Member
hi.. I worked up a little exmaple for you.. so you can look at the code..and how things are set up.. all layers are labeled for you as well.
http://www.dmstudios.net/loadingExternal_demo.zip
(it wont be up to long..post back when you've got it.)
NOW.. you have to read this part..
the MAIN.swf I sent.. has some graphics..some buttons..and an empty movieClip on the stage (containerClip)
the first TWO buttons.. load IMAGES into the containerClip..the LAST button... I load you GALLERY.swf into it. (so you can see how it works)
in the GALLERY.swf I put all the images into a movieClip (called imageHolder)...
I then added bttons to the galleery .swf as that is how I chose to 'switch back and fourth between the images inside the IMAGEHOLDER movieClip.
Once you under stand about loading things into 'targets' (or containers).. you can add preloader(s) to watch these containers... and display how much (percentage) i currently being loaded into THAT container. you can have as many conainers as you like..and as many preloaders as you like. once you get more skilled..you will learn how to re-use the stuff in your movies over and over.
-
Very cool. I've downloaded the file (examples always make things easier). I'll study it, try it out, work with it- the whole deal and report. Thanks again so much for your help!
-
Okay- I know how to reference a frame on the main timeline by using _root.goto etc.etc. How do I do the opposite and reference a frame in a movieclip from the main timeline?
-
Senior Member
-
Yes- very easy! That helps a lot.
(I'll be back here in the next few days to report about the other stuff in this thread...)
-
 Originally Posted by whispers
you just put the movieClip name in the path..  same code..
before:
_root.gotoAndPlay(2);
now:
_root.movieClipName.gotoAndPlay(2);
easy huh?
you'll be a pro in no time. 
Okay- what about making a path to a movie clip contained within a button?
(I try to look these questions up in the help section of Flash but I rarely seem to be able to find my answers there.)
-
Senior Member
cant be done.. anywhere..with a preloader..without one..anything.
you can NOT target a movieClip that is embedded in one of the buttons 'states'
-
 Originally Posted by whispers
cant be done.. anywhere..with a preloader..without one..anything.
you can NOT target a movieClip that is embedded in one of the buttons 'states'
I read this response and instantly realized what I should be doing to accomplish this same thing (simply add another "hit area" to the original button so that people can either click an icon on the page or some text at the bottom to accomplish the same thing- worked perfectly).
Okay- I studied and played with the example you made on how to load content into targets. Makes perfect sense and is incredibly simple- being able to explore that file made all the difference.
I am now implementing it into my site and ready to think about preloaders again for these external files. I am thinking of using the one I listed at the top of this thread for when my site initially loads (with accompanying images/movieClip, of course). Now I need to figure out how to do preloaders for various containers within the site. Thanks again for all your help!
-
Senior Member
preloader links in my footer will help you understand when your ready.
and just understand, that when you have a preloader, it needs to watch something.. a container (_level), that the content is being loaded into... this is the target..
-
I looked at some of the tutorials and thought I'd be brave enough to apply the preloader in my original post (which jumps back and forth between two frames until everything's loaded and then goes to frame 3). I got this working great for when the site opens, but can't seem to get it working for an individual containerClip. Maybe I'm referencing it wrong?
So do I change:
totalBytes = this.getBytesTotal();
loadedBytes = this.getBytesLoaded();
to:
totalBytes = _root.containerClip.getBytesTotal();
loadedBytes = _root.containerClip.getBytesLoaded();
That's what I tried and it's not working. I'd be willing to use a different method, even. All I want to do is a simple animation (almost like a thermometer) that's 100 frames and "fills" as it loads. I did look at some of the other tutorials but was hoping that a simple change of what I already had used successfully would be the easiest.
Thanks...
-
In my confusion I have gone back to some of the old threads and now see that you don't recommend the antiquated method I am using. I'll go look at your ezPreloader again. I did try to understand it earlier and had a bit of trouble. What I'd like to do visually (and I'm now proposing I base this on your ezPreloader) is have a window that fills with water comparable to the amount the external .swf has loaded- in other words have an animation of 100 frames that corresponds to the amount it is loaded instead of the rotating circle, but I don't know how to make the alterations...
Edit: I'd also consider the one you propose in this thread (post #3), but without the attached .fla mentioned (at least I didnt' see it) I can't figure it out...
Last edited by progfellow; 05-15-2007 at 06:22 PM.
Reason: addition
-
Senior Member
my ezPreloader is an already built preloader with a set animation.. there is no 'water filling' or anythign besides the spinning arrows animation that is available with my ezPreloader component.
If you want to follow the link in my footer called preloader 1 then you can do as you proposed..as it is the SAME THING as you want to do..except the 10 frame long animation is a tweening bar instead of a tweening 'water fill' movieClip.
the 3 preloader links in my footer are ALL different.
#1 is the one you descibe above using a 100 frame long animation to display the percentage of the content being loaded.
#2 is using 100% code to create all graphics including the progress bar animation and all preloader routine (code)
#3 is the component I made.. you DO NOT HAVE TO KNOW ANY CODE.. you just drag it to the sdtage...fill in some parameters.. and thats it..
-
I have read all three threads pretty intensively- the problem is I'm a Flash ignoramus.
(Yes, i do realize your ezPreloader didn't have a water animation- I was just saying that is what I am going to do.)
It sounds like your #1 option is what I need to do. I just have a hard time following it since the .fla is no longer available. (I'm a visual learner )
I'll look at it again and tell you where you're losing me...
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|