View Full Version : Listeners & MovieClipLoader
xdeliriumx
07-01-2005, 03:08 AM
I'm having some issues with the movieClipLoader -> mainly, my onLoadProgress statements don't seem to execute at all. I have a preloader with a bar that *should* grow, along with a percentage below it that should change. Nothing happens until onLoadComplete...
// *** While loading = Display progress on bar & percentage
preloadListener.onLoadProgress = function (target_mc:MovieClip, lBytes, tBytes)
{
bar._width = (lBytes / tBytes) * 100;
percentText.text = Math.round ((lBytes / tBytes) * 100) + " %";
var loadProgress:Object = myMCL.getProgress (target_mc);
var tBytes:Number = loadProgress.bytesTotal;
var lBytes:Number = loadProgress.bytesLoaded;
var percentage:Number = Math.ceil ((lBytes / tBytes) * 100);
percentText = percentage;
trace( percentage );
};
I tried throwing traces in, but it's like this function is skipped completely. Any ideas? I can post the rest of the code if necessary... Thx!
misspelledyouth
07-01-2005, 12:45 PM
I suspect that you're having a scope problem here;is this code in a Class file or on the root timeline?
Also, is your onLoadProgress function defined before or after your 'load' call?
If you post a bit more code it might be more obvious :-)
xdeliriumx
07-01-2005, 02:28 PM
I'll post the code in it's entire (I'm new to actionscript, so it may look a little sloppy).
I did not have the variable loadProgress defined before I referenced it, although I did change this and it still seems to skip over the function. The code is on my root timeline too.
Maybe, just maybe, it is because I am using an array and I need to somehow trigger that function???
stop ();
//Define variables
_global.gCount = 0;
//Define array values
preload_arr = new Array ("01", "02", "03", "04", "05", "06", "07", "08", "09", "10");
//Define listener and moviecliploader
var myMCL = new MovieClipLoader ();
percentText.visible = true;
nextScene_btn._visible = false;
// *** Start loading = Make objects visible on loader
myMCL.onLoadStart = function (target_mc)
{
var loadProgress:Object = myMCL.getProgress (target_mc);
bar._visible = true;
border._visible = true;
percentText._visible = true;
};
// *** While loading = Display progress on bar & percentage
myMCL.onLoadProgress = function (target_mc, tBytes, lBytes)
{
var tBytes:Number = loadProgress.bytesTotal;
var lBytes:Number = loadProgress.bytesLoaded;
bar._width = (lBytes / tBytes) * 100;
percentText.text = Math.round ((lBytes / tBytes) * 100) + " %";
trace ("It Worked");
var percentage:Number = Math.ceil ((lBytes / tBytes) * 100);
percentText.text = percentage;
};
// *** On completion = Display all objects, including enter button
myMCL.onLoadComplete = function (target_mc)
{
var loadProgress = myMCL.getProgress (target_mc);
border._visible = true;
bar._visible = true;
percentText._visible = true;
nextScene_btn._visible = true;
};
// *** Error handling
myMCL.onLoadError = function (target_mc, errorCode:String)
{
trace ("Error - " + target_mc);
};
//Call function that defines prefixes
setPrefix ();
function setPrefix ()
{
for (var gCount = 0; gCount < 6; gCount++)
{
if (gCount == 0)
{
prefix = "w_";
initPreload ();
}
else if (gCount == 1)
{
prefix = "w2_";
initPreload ();
}
else if (gCount == 2)
{
prefix = "w3_";
initPreload ();
}
else if (gCount == 3)
{
prefix = "w4_";
initPreload ();
}
else if (gCount == 4)
{
prefix = "p_";
initPreload ();
}
else if (gCount == 5)
{
prefix = "g_";
initPreload ();
}
}
}
for (var i = 0; i < preload_arr.length; i++)
{
_root.createEmptyMovieClip ("thumb" + i + "_mc", this.getNextHighestDepth ());
_root.myMCL.loadClip ("thumbnails/" + prefix + preload_arr[i] + "_tn.jpg", "thumb" + i + "_mc");
_root["thumb" + i + "_mc"]._x = 1000;
}
nextScene_btn.onPress = function ()
{
nextScene ();
};
Billystyx
07-01-2005, 02:49 PM
try uploading the files and testing on the server - do they work now?
loadProgress will not work in the test environment.
billystyx
Ain't that a kick in the head...??? - Sinatra
xdeliriumx
07-02-2005, 05:17 AM
Makes sense that loadProgress wouldn't show during debugging, however I did upload and am still having the problem.
The progress bar doesn't seem to work, nor does the text box that should reference the percentage loaded... maybe it's just something silly, I'll do another look over of my fla. Thanks for the suggestions - any more helpful input would be appreciated! :)
vBulletin® v3.7.1, Copyright ©2000-2009, Jelsoft Enterprises Ltd.