Arekaine
04-17-2005, 11:19 PM
So I have this very simple movie. It is however very large and needs a preloader. The simple progress bar would work well enough. Problem is, I have no clue how to make it work. I placed it on the stage and set all it's properties. Then when I test the movie it doesn't show up. I really suck at components. Is there Action script I need to put on it? Please help a noob
frankfenten
04-19-2005, 02:40 PM
It's really lame and full of bugs. I had real grief with it.
One thing you'll need to get your head around in flash is the idea of listeners. I know it's quite a tough one for a noob - especially if you aren't used to event-driven models generally, but still...
Loading is now listener-driven. You create a loading 'thing' (usually called an object) that shouts out what it's doing all the time. It shouts 'hello, I've started loading', 'I'm now 20,30,40,50% loaded', 'FINISHED' and a couple of others. If you know how to listen to those shouts, you can grab what it's saying and output it to screen. The code below gives an example of how to do that.
for more help, look in the documentation, but this should put you on the path. I know, it's unecessarily complicated and has even veteran flashers scratching tgheir heads, but it's the WAY.
//load login movie
function loadNewMovie(movieName) {
// sort out some vars
var mLogin_mcl:MovieClipLoader = new MovieClipLoader();
var loginListener:Object = new Object();
var percentLoaded
// the load has just started
loginListener.onLoadStart = function(target_mc:MovieClip) {
trace("*********Load Start*********");
trace("Your load has begun on movie clip = "+target_mc);
var loadProgress:Object = mLogin_mcl.getProgress(target_mc);
trace(loadProgress.bytesLoaded+" = bytes loaded at start");
trace(loadProgress.bytesTotal+" = bytes total at start");
loadedLogin_mc.loadingIn_txt.text = "Log In";
};
// this happens when theres some load progressing
loginListener.onLoadProgress = function(clip, bytesLoaded, bytesTotal, target_mc:MovieClip) {
trace("*********Load Progress*********");
trace("onLoadProgress() called back on movie clip "+target_mc);
trace(bytesLoaded+" = bytes loaded at progress callback");
trace(bytesTotal+" = bytes total at progress callback");
// put the % loaded into a text box
percentLoaded = int (100*(bytesLoaded/bytesTotal));
trace(percentLoaded+"% loaded"); // works
_level0.loadedLogin_mc.progress_txt.text = percentLoaded + "% loaded"; // works, cheers g
};
// load is complete, can specify events to happen now
loginListener.onLoadComplete = function(target_mc:MovieClip) {
trace("*********Load Complete*********");
trace("Your load is done on movie clip = "+target_mc);
var loadProgress:Object = mLogin_mcl.getProgress(target_mc);
trace(loadProgress.bytesLoaded+" = bytes loaded at end");
trace(loadProgress.bytesTotal+" = bytes total at end");
// the percent thing hides when load complete
_level0.loadedLogin_mc._visible = false;
target_mc.play();
};
// i think is saying that frame one of the loaded movie is has played
loginListener.onLoadInit = function(target_mc:MovieClip) {
trace("*********Load Initialized*********");
trace("Movie clip = "+target_mc+" is now initialized");
};
// add the listener thing to the load
mLogin_mcl.addListener(loginListener);
// Now load the files into their targets
// first, define the file to be loaded
clipPath = connectStartString + "images/fla/" + movieName
trace("clipPath: "+clipPath)
mLogin_mcl.loadClip(clipPath, loginHolder_mc);
}
hope this helps.
Cheers,
Frank
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.