I just made a revamped version of my ezPreloader_v1.0 component. (called: ezPreloader_v2.0)
so without further 'ado', here is the documentation and .mxp (component) file
install as you normally would install any Flash component (Extension manager)
You can mix and match any colors/styles/sizes/speed to match your project
Documentation:
Welcome to the ezPreloader_v2.0 component.
A light weight, easy to use, full customizable preloader component.
This component makes use of the MovieClipLoader(): class, and along with letting you set a number of physical parameters (to control its look), you can also define the content you want to load (loadSource) and where you want to load it (loadTarget).
Those are basically the only two parameters that are REQUIRED for the component to work. The rest are optional
Because this component uses the MovieClipLoader(); class, it also allows us to make use of the listener/callBack functions. This is great for basing other actions or functions depending on the current state of the content being downloaded. The returned data from these callBacks helps power the ezPreloader_v2.0 conponent and is also passed onto any custom callback functions you may want to register and ustilize the same data.
I go into more details below.
User Controlled Component Properties:
Code:
PROPERTY: VARIABLE NAME: DESC:REQUIRED:
Load Source (Property Var: loadSource:String) Defines the content (.swf/image/video) to load
Load Target (Property Var: loadTagret:String) Defines the target (containerClip/_level) to load into
OPTIONAL:
Height (Property var= uHeight:Number) Controls the height of the rotation/animation
Width (Property var= uWidth:Number) Controls the width of the rotation/animation
Rotation Speed (Property var= uSpeed:Number) Controls the speed of the rotation/animation
Rotation Visible (Property var= uVisible:Boolean) Controls the visibility of the rotation/animation
Color Choice (Property var= uColor:Color) Defines the color of the rotation/animation
Rotation Alpha (Property var= uAlpha:Number) Defines the alpha of the rotation/animation
Text Color (Property Var= tColor:Color) Defines the color of the percentage text
Text Alpha (Property Var= tAlpha:Number) Defines the alpha of the percentage text
Text Size (Property Var= tSize:Number) Defines the size of the percentage text
Text Visible (Property Var= tVisible:Boolean) Controls the visibility of the percentage text
CallBack Register Vars (and returned parameters)
completeCallback:String = >>Returns: (targetMc:MovieClip, httpStatus:Number)
errorCallback:String = >>Returns: (targetMc:MovieClip, errorCode:String, httpStatus:Number)
initCallback:String = >>Returns: (targetMc:MovieClip)
progressCallback:String = >>Returns: (targetMc:MovieClip, loadedBytes:Number, totalBytes)
startCallback:String = >>Returns: (targetMc:MovieClip)
Function Name: Desc:
startLoad(loadSource, loadTarget); Start the load of the loadSource into the loadTarget
Summary of usage:
Ther are basically three ways the ezPreloader_v2.0 preloader can be used.
The first two involves dragging the component to stage in the authoring environment.
(Article assumes you have already successfully installed the ezPreloader_v2.0 component and it resides in your Flash IDE in the compoenents panel under the ezConponents folder)
1.)(auto load/manual settings) The component is draged on the stage from the component panel onto the stage. Once the component is on the stage, you select/highlight it, and go to the properties panel and under the parameters tab you can set the options to match your project. The only properites that need to be set as the loadSource & loadTarget parameters. Once the component is on stage (and these parameters are filled with valid values) it will automatically start the load when your movie starts.
2.)(manual load/manual settings) The component is draged on the stage from the component panel onto the stage. Once the component is on the stage, you select/highlight it, and go to the properties panel and under the parameters tab you can set the options to match your project. For this method (or not to automatically start loading your content when the movie starts) you should leave the loadSource & loadTarget parameters as alone or blank. You must also remember to give your component an INSTANCE NAME, so you can trigger the load action from another event (button click or something). The component has a public function call startLoad();. This function also accepts two parameters that are required.
startLoad(loadSource, loadTarget);
Those parameters are: loadSource: (which is the content you want to load) loadTarget: (which is the target you want to load your content into)
If you didnt want to set any of the physical attribute parameters.. the minimal steps for using method #2 would be as follows:
Code example: (assuming component is on stage with INSTANCE NAME of: ezPreloader)
PHP Code:
//create empty clip to load content into
var containerClip:MovieClip = _root.createEmptyMovieClip("containerClip", _root.getNextHighestDepth());
button_btn.onPress = function(){
//load code for manually placed components
ezPreloader.startLoad("imagename.jpg", containerClip);
}
3.)(manual load/dynamic setting) the 3rd & final method I see the that can be used is attching the component dynamically like most other movieClip/component are. You follow the same rules/code you would use to attach any other clip to the stage and assign properties to it once it initializes. This means that not only do you have to set all physical atributes through code, but you must also set the REQUIRED parameters: loadSource & loadTarget.
NOTE: If you assign the REQUIRED parameters: loadSource & loadTarget upon attaching/initializing of the clip.. it will start to load content automatically (3a). If you do not assign the required parameter a values upon attachign the clip, you have to invoke the loading manually through another action with the startLoad(); function. (3b)
Code example: (assuming component is on stage with INSTANCE NAME of: ezPreloader)
Every ezPreloader_v2.0 component has 5 callBack vars that you can use to register your OWN functions that get executed/triggered. when you list a function to use as that callbacks registered function, it also gets passed certain parameters that you can take advantage of and use in yoru callBack functions. (above is the chart that lists what callback function pass what parameters.
Here is an example of how to make you own functions and use the data passed in as parameters. (function names have to match the vars you give the callBack vars.
PHP Code:
//create callBack functions:
// create function that fires/executes when the content is loading
function onProgress(target_mc:MovieClip, bytesLoaded:Number, bytesTotal:Number):Void {
trace(target_mc._name + ".onLoadProgress with " + bytesLoaded + " bytes of " + bytesTotal);
trace(">> Invoked every time the loading content is written to the hard disk during the loading process (that is, between MovieClipLoader.onLoadStart and MovieClipLoader.onLoadComplete).");
}
// create function that fires/executes when the content is complete
function onComplete(target_mc:MovieClip, httpStatus:Number):Void {
trace(">> targetListener.onLoadComplete()");
trace(">> =============================");
trace(">> "+target_mc._name+"._width: " + target_mc._width);
trace(newline);
};
// create function that fires/executes when the content has initialized and is ready for manipulation
function onInit(target_mc:MovieClip):Void {
trace(">> targetListener.onLoadInit()");
trace(">> =============================");
trace(">> "+target_mc._name+"._width: " + target_mc._width);
trace(newline);
};
function onStart(targetMc:MovieClip):Void {
trace(">> targetListener.onLoadStart() fired");
trace(">> =============================");
trace(newline);
};
function onError(targetMc:MovieClip, errorCode:String, httpStatus:Number):Void {
trace(">> targetListener.onLoadError() fired");
trace(">> =============================");
trace(newline);
};
If those 3 methods above are still confusing, may this will help clarify:
"If the REQUIRED variables/properties: loadSource & loadTarget are given values when the clip is initialized (whether you dynamically attach or place on stage in the IDE) the clipLoader will automatically begin your load routine.
This should about wrap up the documentation on to use the ezPreloader_v2.0 conponent. I hope you enjoy it and find it easy to use.
If you have any questions, comments or sugestion on how to make the ezPreloader_v2.0 component better please drop me a line.
unfortunately..the more I learn.. the more I see these as 'knock-offs' of what 'could be' if I learned OOP properly and started writing my own classes.
anyways.. any feedback or links to it 'in action' are always nice..
This is really great, but I'm confused.
I want to use this to preload my entire movie swf
(put the preloader is scene 1, then have it jump to scene 2 when my swf is loaded).
How do I set Load Source and Load Target for this?
Thanks!
Before it dies again, I'll throw a punch--still don't get the level. I tried putting 0/_level 0/_level.0/level:0 for the target, and it doesn't load. Works fine when I use mcs though. Is there like a prefix that I need to put so the component can realize it's a level and not a clip?
well it was never designed to be used with _levels.. and 'thought' others have had success putting in the _level1 value in the params.. but maybe Im wrong?
this seems to work..although its from a button event.. (and has quotes around it)
whispers --- I know this is an old thread, but i LOVE this component!!!
it's great!
I just wish there was a way to go in and change the way it looks from the spinning wheel. Really get in and change it to anything.
Quick question ... When loading images from the web, the "errorCallback" dosnt seem to work if flash is blocked by my firewall, or if the images is unavailable. It just keeps looping and looking for it.
1.) if you could totally change it (aside from the size color/alpha percentage)..it would defeat the purpose of making a 'component'...no?
2.) the onError() is taken directly from the MovieClipLoader() class in flash...
have you tried to trace out anything?
you'd have to read more into the MovieClipLoader() class to see how it handles firewalls, or unavailable images..
actually (since I never use it).. I believe it should be onLoadError().. I'll have to go back and re-compile the component... if its like that in there..
I'm still working on a project that uses your ezPreloader component.
But i'm having a real strange problem.
For some reason, the percentage text inside the circle doesnt always show. The spinning disk will always work fine, but the text will not show up.
I'm sure this is somthing to with the way flash is loading my app (it's all in parts in many swfs).
I have one swf that is nothing but a preloader. -- and that should solve the problem with the export in first frame.
Do you have any ideas? the ezpreloader works great -- but if the text does not load, there is no way to get it back, even chaning the text alpha or anything.
The ezPreloader will work -- the disk will spin, but there is no text.
does the animation (spin) go away eventually?..or does it just sit there?
Yep, it goes away -- it works perfect. 100% working great. It comes back when i need it to aswell -- but the text inside doesnt show up (somtimes -- it appears to be random depending on the loading of the swf)
Originally Posted by whispers
it isnt meant to load multiple images/content..
1 ezPreloader per content loading..
Yes, thats how im using it -- there is one on stage -- it loads an image/swf -- and waits until the init is finished - then loads somthing else. It is working great. so im sure this isnt the problem.
Originally Posted by whispers
there is a multiLoader class floating around here created by memeber MyFriendIsATaco.. if you want to use that..but its just a class..
I'd rather use yours it's doing a great job! And is exactly what im looking for. It just dosnt seem to be loading the centre text sometimes. Which is so strange when the component is working great. and the disk spins good.