Ultrashock Forums > Flash > ActionScript
[mini-tutorial] MovieClipLoader

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rating: Thread Rating: 6 votes, 4.33 average. Search this Thread | Thread Tools | Display Modes
<|1|2| Page 2 of 2
Julian's Avatar Julian Julian is offline Julian lives in United States 2 Creative Assets 2004-12-18 #41 Old  
Originally posted by macronesia
guys, bluebox you use que as an MCL class, you don't even have a listener... thus making the code invalid.
Yeah that code is pretty messy, I've noticed a lot of other bugs in it since I did my V2 preloaders.

Get on AIM (nevrrain) and I'll give you my code to play mc(s) instead of text.

(nr)
Reply With Quote  
macronesia macronesia is offline 2004-12-23 #42 Old  
well, i am already miles ahead now... after a few hours of testing I built a pretty nice preloader utilizing the class.. so i don't need help with it anymore.
Reply With Quote  
Julian's Avatar Julian Julian is offline Julian lives in United States 2 Creative Assets 2004-12-23 #43 Old  
Originally posted by macronesia
well, i am already miles ahead now... after a few hours of testing I built a pretty nice preloader utilizing the class.. so i don't need help with it anymore.
The class? You mean you used the moviecliploader class? That's what I used and it works well.
Reply With Quote  
westbrent westbrent is offline westbrent lives in United States 2005-01-05 #44 Old  
problem with bytesTotal return
A related question on this. I have a loader bar working, and I also have a text member reading “X kb of XX kb loaded” and it all seems to work well. But then I noticed that the total load number is not coming up right. when I run “getBytesTotal” it is returning a value of 202kb, (206848 / 1024), however the exported swf file is only 149kb. The proportion to which the bytesTotal and the actual swf file is off is not consistent between different clips. Has anyone run into this, or know a way around it?
-Thanks
Reply With Quote  
assimetric assimetric is offline 2005-01-16 #45 Old  
why don't work here?
class com.fi.framework.common.DataLoader
{
function DataLoader () {
}
static function loadMedia(mcTarget, strURL, objScope, fnOnLoaded, fnOnProgress) {
var _loader:Object = new Object();
var _local3:MovieClipLoader = new MovieClipLoader (); //dont work
trace(_local3);
_loader.onLoadInit = function (mcTarget) {
fnOnLoaded.apply(objScope, ["success", mcTarget]);
};
_loader.onLoadError = function (mcTarget, strErrorCode) {
trace("load error");
fnOnLoaded.apply(objScope, [strErrorCode, mcTarget]);
};
_loader.onLoadProgress = function (mcTarget, numBytesLoaded, numBytesTotal) {
trace("load progress");
fnOnProgress.apply(objScope, [numBytesLoaded, numBytesTotal, mcTarget]);
};
_loader.onLoadStart=function(){
trace("load started");
}
_loader.onEnterFrame=function(){
trace(2);
}
if ((fnOnLoaded != null) || (fnOnProgress != null)) {
_local3.addListener(_loader);
}
_local3.loadClip(strURL, mcTarget);
}
static function loadXML(strURL, objScope, fnOnLoaded) {
var _local2 = new XML ();
_local2.ignoreWhite = true;
_local2.onLoad = function (boolSuccess) {
if (boolSuccess) {
fnOnLoaded.apply(objScope, [this]);
}
};
_local2.load(strURL);
}
}
Reply With Quote  
Andreas-De Andreas-De is offline 2005-01-18 #46 Old  
@westbrent
the difference is caused by compression.
202kb is the uncompressed size, and it has been reduced to 149kb with compression.
When you uncheck "compress movie" in the Flash Export settings, the file will also make up 202 kb.
Reply With Quote  
digimat digimat is offline 2005-01-18 #47 Old  
A-dude, I can't seem to get your MCL code to work...

One thing I noticed was that in the loadVar section your refrencing level5 when the preloader is being loaded into 50.

anyone else have problems with this script?
Reply With Quote  
 Mime 2005-01-30 #48 Old  
Thanks for your email reply digimat. I hope it worked out for you in the end.
Reply With Quote  
ice_boxmx ice_boxmx is offline 2005-01-31 #49 Old  
is this also applicable to flash mx?
Reply With Quote  
NewEzra's Avatar NewEzra NewEzra is offline NewEzra lives in United States 2005-01-31 #50 Old  
Originally posted by ice_boxmx
is this also applicable to flash mx?
No not at all... MovieClipLoader is a class that's new to 2004.
Reply With Quote  
theone2 theone2 is offline 2005-02-06 #51 Old  
great stuff, man.. I always wondered how to make this process easier.. and now i can continue on my project.. thnx!
Reply With Quote  
tenant13 tenant13 is offline tenant13 lives in United States 2005-02-21 #52 Old  
I tried to control an additional element with the MCL code but somehow it doesn't seem to work. Specifically I created a text field on the very first frame of the timeline to ensure that the screen has something on it before the preloder kicks in:
ActionScript Code:
  1. this.createTextField ("loadingAssets_txt", 10, 216, 284, 207, 15);
  2. loadingAssets_txt.text = "PLEASE STAND BY - LOADING ASSESTS";

Then I'm using the simple version of the preloader:
ActionScript Code:
  1. var myMCL:MovieClipLoader = new MovieClipLoader ();
  2. var myListener:Object = new Object ();
  3. myListener.onLoadProgress = function (target_mc, loadedBytes, totalBytes) {
  4.     _level10._visible = true;
  5.     _level50._visible = true;
  6.     var preloadPercent:Number = Math.round ((loadedBytes / totalBytes) * 100);
  7.     _level50.preloaderBar.gotoAndStop (preloadPercent);
  8. _level50.preloadInfo1.text = preloadPercent + " %";
  9. };
  10. myListener.onLoadComplete = function (target_mc) {
  11.     _level10._visible = false;
  12.     _level50._visible = false;
  13. };
  14. myMCL.addListener (myListener);
  15. myMCL.loadClip ("preloader.swf", 50);

Everything is working fine with a preloader but the text field stays put and does not disappear.
What am I doing wrong?
Reply With Quote  
pisosse pisosse is offline pisosse lives in Denmark 2005-03-05 #53 Old  
This is my first at this place but from what i've read ur pretty friendly

I got this code from frozenmedia @ flashmove that should put me in position to load different swfs into the same holder by pushing different buttons and sharing the same animated preloader. . But the preloadbar is a no show.

ActionScript Code:
  1. //SWF LOADER
  2.  
  3. function loadSWF(swf:String)
  4. {
  5.         var holder_mc:MovieClip = createEmptyMovieClip("holder_mc", 0);
  6.         var preloader_mc:MovieClip = attachMovie("preloader_mc", 2);
  7.  
  8.         var mcl:MovieClipLoader = new MovieClipLoader();
  9.         var mclListener:Object = new Object();
  10.  
  11.         mclListener.onLoadProgress = function(target_mc:MovieClip, loadedBytes:Number, totalBytes:Number)
  12.         {
  13.                 preloader_mc.gotoAndStop(Math.round(percent));
  14.         }
  15.         mclListener.onLoadInit = function(target_mc:MovieClip)
  16.         {
  17.                 preloader_mc.removeMovieClip();
  18.                 target_mc.play();
  19.         }
  20.  
  21.         mcl.addListener(mclListener);
  22.         mcl.loadClip(swf, holder_mc);
  23. }
  24.  
  25. // Button code
  26. pri_mc.onRelease = function()
  27. {
  28.         loadSWF("http://www.mentalindustries.com/rmov.swf");
  29. }

I wonder what i'm missing.. The preloader_mc is in the libery with a linkage identifyer and are a 100 frame shapetween with a stop action in frame 1.

thanks for any help and sorry for bothering u with newbie quistions like this
Reply With Quote  
jaseinatl jaseinatl is offline jaseinatl lives in United States 2005-03-06 #54 Old  
Tenant13,
I have two thoughts on the matter and was hoping to get some input about them:

First, I wondered if it is because the reference to level10 in the first frame of your movieClip (which is being born on level50)is a different level10 (perhaps a level10 from the level50 perspective) than referred to by the movieClip Loader's reference to level10 (which is on level0 of the _root timeline)?

I am not sure, so I thought I would ask. Also, maybe this would work:


in your first frame:
ActionScript Code:
  1. _global.preloadMessage=this.createTextField ("loadingAssets_txt", 10, 216, 284, 207, 15);
  2. loadingAssets_txt.text = "PLEASE STAND BY - LOADING ASSESTS";

then in your preloader definition:
ActionScript Code:
  1. myListener.onLoadComplete = function (target_mc) {
  2.      _global.preloadMessage="";
  3.         _level10._visible = false;
  4.         _level50._visible = false;

If these are stoopid responses, please forgive the post and be kind in correcting me. Let me know either way.

Best wishes,

jase
Reply With Quote  
pisosse pisosse is offline pisosse lives in Denmark 2005-03-10 #55 Old  
I got it thanks to Netrox...

Was missing a percentage decleration ops:

thanks
Reply With Quote  
outcast outcast is offline 2005-05-23 #56 Old  
Don't worry bout it I found it refresh itself I forgot to clear the temp frist. Great tut helped me alot
Reply With Quote  
crees crees is offline 2005-08-22 #57 Old  
Originally posted by laco
i dont use MovieClipLoader, Bokel has writen Loader Class http://www.helpqlodhelp.com/stuff/lo...rclass1.02.zip
It runs fine too under FP6 and has many cool features
Is this Bokel/Moock LoaderClass what was actually implemented in the current MovieClipLoader class? I see the last revision to the Bokel/Moock was 2 years ago. Just wondering how this holds up to the features in MCL if they're not the same. Sorry if this has been asked before? Just wondering if one is "better" than the other.

\m/
Reply With Quote  
tasuki tasuki is offline 2005-09-07 #58 Old  
yeah.........thankx bluebox ive got my minisite finished....youve answer the q??? how great you are...waaaaaaa......i know now what i need for my next thing to do....weeeeeeeeee...^_^
Reply With Quote  
phlop phlop is offline 2006-01-23 #59 Old  
I am using this preLoading sytem...

I cannot get the preLoader.bar to move while it is loading...

It sets the xScale to 0, and then waits while it loads, and then sets it right to 100 when its done.... Can someone help me? Here is the code.

ActionScript Code:
  1. /// MCLOADER ////////////////////////////////////////////////////////////////
  2. /////////////////////////////////////////////////////////////////////////////
  3. var queCL = new MovieClipLoader();
  4. _global.allLoaded = false;
  5. queCL.onLoadStart = function(targetMC) {
  6.         var loadProgress = queCL.getProgress(targetMC);
  7.         preLoader._visible = true;
  8.         preLoader.bar._xscale = 0;
  9. };
  10. queCL.onLoadProgress = function(targetMC, loadedBytes, totalBytes) {
  11.         myDiviser = Math.round(loadedBytes/targetMC.totalBytes*100)
  12.         preLoader.bar._xscale = myDiviser;
  13. };
  14. queCL.onLoadComplete = function(targetMC) {
  15.         var loadProgress = queCL.getProgress(targetMC);
  16.         preLoader.bar._xscale = 100;
  17.         if (objectsToLoadQue.length != 0) {
  18.                 objectShifted = objectsToLoadQue.shift();
  19.                 targetShifted = targetsQue.shift();
  20.                 queCL.loadClip(objectShifted, targetShifted);
  21.         } else {
  22.                 delete objectsToLoadQue;
  23.                 delete targetsQue;
  24.                 preLoader.bar._xscale = 100;
  25.                 allLoaded = true;
  26.                 preLoader._visible = false;
  27.         }
  28. };
  29. queCL.onLoadInit = function(targetMC) {
  30. };
  31. queCL.onLoadError = function(targetMC, errorCode) {
  32. };

ActionScript Code:
  1. this.attachMovie("preLoaderLib", "preLoader", 5000);
  2. preLoader._visible = false;
  3. preLoader._x = "350";
  4. preLoader._y = "350";

ActionScript Code:
  1. objectsToLoadQue = new Array();
  2. targetsQue = new Array();
  3. objectsToLoadQue = [randomBG(), 'jmMusic.swf'];
  4. targetsQue = [_root.backgroundClip, _root.audioClip];
  5. queCL.loadClip(objectsToLoadQue[0], targetsQue[0]);

ActionScript Code:
  1. function randomBG(){
  2.     randomNumber = random(10);
  3.     randomBackground = "BG"+randomNumber+".jpg";
  4.     return(randomBackground);
  5. };


Whats going wrong? The clips are being loaded sequentially just fine, but I see no progress.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2006-01-23 #60 Old  
Try changing this line...

ActionScript Code:
  1. myDiviser = Math.round(loadedBytes/targetMC.totalBytes*100);
... to this ...

ActionScript Code:
  1. myDiviser = Math.round((100 / totalBytes) * loadedBytes);
Reply With Quote  
phlop phlop is offline 2006-01-23 #61 Old  
Awesome. Works like a charm!
Reply With Quote  
Mike-Jones Mike-Jones is offline 2006-02-03 #62 Old  
Could you post a sample .fla so some of us non coders can get visual feel for how this works and where its supposed to go etc.....so like exactly what I have bben searching for for the past 2 days......

Respectfully,
Mike Jones
Reply With Quote  
Mike-Jones Mike-Jones is offline 2006-02-03 #63 Old  
Please somebody? I have no idea where to put the code or what to do to get the useage he described in the beginning to go?
Reply With Quote  
Julian's Avatar Julian Julian is offline Julian lives in United States 2 Creative Assets 2006-02-13 #64 Old  
Originally posted by Mike Jones
Please somebody? I have no idea where to put the code or what to do to get the useage he described in the beginning to go?
Mike, you forgot to post the FLA I made to help you out with on the forums for other people.

http://www.neverrain.net/misc/ineedadime.fla (File name especially for Mike Jones)

Julian
Reply With Quote  
moonstream's Avatar moonstream moonstream is offline moonstream lives in Serbia and Montenegro 2006-03-13 #65 Old  
Last edited by moonstream : 2006-03-14 at 11:22.
/* Solved, pls delete this post
Hi,
first thanx for this tutoria, it's a great help. Anyhow, now that i've put it to use for the first time, i have some strange issues...
First, the first MC in the que loads twice... Anyone encountered something similar?
And second, for the last clip in que, the progres bar doesn't scale to full size, but stays around 70% or so...
Anyone have ideas how to sort this?

/*Edit :
Sloved this:
One more thing :
How can i set the preloader to wait untill all the files are loaded, and start playing then??
*/

Thanx in advance
*/
Reply With Quote  
sermed sermed is offline 2006-03-25 #66 Old  
your site is very beautiful how you create the motion of the
house ??????
Reply With Quote  
xxcn2006 xxcn2006 is offline 2006-11-17 #67 Old  
i want to know,what is PEDALSPEED?
Reply With Quote  
Zee Zee is offline Zee lives in United States 2006-11-17 #68 Old  
PEDALSPEED is a member on this forum, not software or anything like that.
Reply With Quote  
xxcn2006 xxcn2006 is offline 2006-11-17 #69 Old  
ohh.i got that,thx~




very good tutorial~ i like it
Reply With Quote  
tawfekov tawfekov is offline 2007-03-15 #70 Old  
i hav asked already
about using movieclip loader class
and i wish i will find the answer here
i'll read it all
and also
thx 4 u
Reply With Quote  
skull_demo skull_demo is offline 2007-05-25 #71 Old  
hi could somebody tell me how do i load a external swf file into flash using loadMovie so that we can put it in a specific place, if i dont have the .fla file?
i Would appreciate some help
plz submit a reply as soon as possible
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2007-05-25 #72 Old  
Originally posted by skull_demo
hi could somebody tell me how do i load a external swf file into flash using loadMovie so that we can put it in a specific place, if i dont have the .fla file?
i Would appreciate some help
plz submit a reply as soon as possible
loadMovie will load an external SWF into a movie clip, so the SWF will appear where ever the movie clip is located.

ActionScript Code:
  1. myMovieClip.loadMovie( "some.swf" );
Reply With Quote  
Silver_S's Avatar Silver_S Silver_S is offline Silver_S lives in Argentina 2007-07-10 #73 Old  
@NewEzra:
man, your code rocks, it saves me at least 2 days programming this thing.
Thanks man.
Reply With Quote  
<|1|2| Page 2 of 2
Thread Tools
Display Modes Rate This Thread
Rate This Thread: