Using a Preloader with looped SWF Problem
by Craig Marshall
on
Jan 27, 2009 at 5:05:16 pm
I made a preloader for an introductory video on a website I am doing. The clients want the video to loop (no problem there). And after discussion they wanted the video to download completely before starting, hence the preloader.
OK, the problem now is that after the download and the first play through, there is a brief glimpse of the preloader before the loop starts again. Is there any way I can, prevent this?
Re: Using a Preloader with looped SWF Problem by Craig Marshall on Jan 27, 2009 at 8:17:04 pm
Sorry, I wasn't sure if the problem was with Dreamweaver or Flash.
Should I repost this on the Flash forum or would that be considered spamming?
I don't know about scenes, my knowledge of Flash is abysmal. The only mention I recall of scenes is at the end of Flash CS4 Visual QuickPro Guide, where it says I should avoid them.
The Flash file is set up on three layers on the timeline: one for actions, one for the preloader and the last for the movie. The actions and the preloader are on frame one and the movie starts on frame two.
Thinking about it, I am wondering if the default looping tells it to go back to frame 1, if so how can I tell it to loop from frame 2?
Re: Using a Preloader with looped SWF Problem by Richard Williams on Jan 27, 2009 at 8:15:00 pm
it looks very much to me like you have embeded the preloader into the SWF of your video... this is the wrong way of doing it. the preloader should be an SWF in its own right, pulling in the detail of SWF that you want to play, running an action script with this type of command...
myLoader.contentPath = "actualvideo.swf";
Re: Using a Preloader with looped SWF Problem by Craig Marshall on Jan 27, 2009 at 8:43:15 pm
Below is the actionscript I used for this I am not sure how I would insert your instructions into this. I am not bright about actionscript (yet, at least).
Re: Using a Preloader with looped SWF Problem by Richard Williams on Jan 28, 2009 at 12:51:17 am
This is how I do it, but it might be bestter explained in the flash forum...?
In the first frame top layer i put this code,
// Create a new Object. The Progress Bar is an object so needs an object function to work
myProgressBarListener = new Object();
/* Create a listener object event function. When the Progress Bar is complete and has preloaded this Movie, the listener will call and run this code below: */
myProgressBarListener = function (eventObject) {
// Hide the Progress Bar - we don’t need it any more as the Movie has now loaded
myProgressBar._visible = false;
// Remove the listener
myProgressBar.removeEventListener("complete", myProgressBarListener);
// Ends the function
};
// Declares a listener. This detects when the Progress Component has loaded the Movie. Then when the preloading is complete it calls the function myProgressBarListener
myProgressBar.addEventListener("complete", myProgressBarListener);
// Set up the Progress Bar Component to polled when loading the Movie. This will give a polled look to the Progress Bar as it loads. It has to be set to polled to work
myProgressBar.mode = "polled";
// Set the location to load as this Movie.
myProgressBar.source = "_root";
then, in the 2nd frame of the first layer,
/* Set the Progress Bar to manual mode so that we can reset its value back to 0. We don't want it staring from 100 ! */
myProgressBar.mode = "manual";
// Reset the Progress Bar back to zero
myProgressBar.setProgress(0, 100);
// Makes the Progress Bar visible
myProgressBar._visible = true;
// Create a listener object event function. The Progress Bar is an object so needs an object function to work
myProgressBarListener = new Object();
// When the Progress Bar is complete and has preloaded this Movie, the listener will call and run this code below:
myProgressBarListener = function (eventObject) {
// Anything you place here will run after the External Movie loads.
// Hide the Progress Bar now that we are done
myProgressBar._visible = false;
// This next section is optional.
// If you wish to remain on Frame 2 and view the External Movie do nothing
// Otherwise un-comment any of the options bellow:
// Plays the Movie from Frame 2 onwards:
// play();
// Go to the next Frame:
// nextFrame();
// Go to the next scene but may not automatically play beyond the Frame 1 in the next scene:
// nextScene();
// Goes to a Frame Label or Frame number and Play:
// gotoAndPlay("myFrameLabel");
// gotoAndPlay(10);
// Go to and stop at the Frame Label or Frame number:
// gotoAndStop("myFrameLabel");
// gotoAndStop(10);
// closes the function
};
/* Declares a listener that detects when the Progress Component has loaded the External Movie. When it is complete it will call the function myProgressBarListener */
myProgressBar.addEventListener("complete", myProgressBarListener);
// Set up the Progress Bar Component to polled
myProgressBar.mode = "polled";
// Set the preloader location of the Progress of the loader Component
myProgressBar.source = "myLoader";
// Set the file name and location of the external swf Movie
myLoader.contentPath = "<b>filetoload.swf</b>";
// Set the external swf Movie scales to fit the loader (true), or the loader scales to fit the content (false).
myLoader.scaleContent = false;
// automatically load the external swf Movie
myLoader.autoLoad = true;
// Stop the Movie at the Frame until the Movie has been preloaded
stop();
I am pretty sure this will just confuse you, so i apologise if this is the case... You could download the preloader off of me and play with it if you like... all you would have to do is load the change the part i have highlighted above to load the movie you want, then at least you can see how it works.