all groups > flash actionscript > may 2006 >
You're in the

flash actionscript

group:

onLoadError won't run when MC doesn't exist


onLoadError won't run when MC doesn't exist Joseph Russavage
5/1/2006 9:04:48 PM
flash actionscript: Can anyone help me?

I am using a movieClipLoader & listener object to dynamically load a SWF. If
the SWF exists onLoadComplete and onLoadProgress work just fine (but only if
they are not within an "if" statement, for some reason) but if the SWF does not
exist onLoadError does not get called.

My MovieClipLoader is attached.

Like I said, everything works but the onLoadError function. Any idea why? I
need to run my function "showRoute" if the map file does not exist. Is there a
work-around?

Thanks for all your help!

~ Joseph Russavage ~

p.s. This is for an interactive acccessibility map I am building for my campus.
You can see this project in progress at www.humboldt.edu/~jmr74 and clicking on
the "Interactive Accessibility Map" link. The above command executes when the
user selects a starting and an ending location from the first two drop-down
menus, then clicks the "Info" button and then the "Route" tab. If there is no
route between the locations the user has selected the onLoadError function
needs to be called to provide other ways to get from A to B.

tabPathOff_btn.onPress = function() {
var prog:Number = new Number;
var routeMap_mcl = new MovieClipLoader();

routeMap_str = "FLASH/ROUTES/" +
currentStartXMLNode.attributes.abreviation +
"-" + currentEndXMLNode.attributes.abreviation + ".swf";
routeMap_mcl.loadClip(routeMap_str, "_root");
routeLoadListener = new Object();
routeLoadListener.onLoadProgress = function(target_mc, loadedBytes,
totalBytes)
{
prog = Math.round(loadedBytes/totalBytes*100);
trace("Loaded " + prog + "%");
}
routeLoadListener.onLoadComplete = function(target_mc) {
trace("Map Loaded...");
}
routeLoadListener.onLoadError = function (target_mc, errorCode) {
trace("Map failed to load..." + errorCode);
showRoute();
}
routeMap_mcl.addListener(routeLoadListener);
}
Re: onLoadError won't run when MC doesn't exist Rothrock
5/1/2006 9:20:11 PM
Not sure. My guess would be that you should move the loadClip to after the
listener code has been defined. Also it is kind of strange ? from my
perspective ? to have all this defined inside the button onPress event handler.
I would have it all outside of that and only have the loadClip in there.

Again and also odd, I have no idea why you would try and put events inside a
conditional. What is that about?
Re: onLoadError won't run when MC doesn't exist shyaway
5/1/2006 9:35:43 PM
Originally posted by: Rothrock
Not sure. My guess would be that you should move the loadClip to after the
listener code has been defined. Also it is kind of strange ? from my
perspective ? to have all this defined inside the button onPress event handler.
I would have it all outside of that and only have the loadClip in there.

Again and also odd, I have no idea why you would try and put events inside a
conditional. What is that about?


the good/bad thing about Flash scripting is that you can be sloppy coding and
everything works fine. But as soon as you apply strict type programming, all
hell break loose :)

But yeah, any sort of listener should be created outside under the main movie
timeline frame on its own. Makes a lot more sense.

Other than that, have you tried create a simpler stand-alone flash file
specifically only does this MCL? try that and see what happen

Re: onLoadError won't run when MC doesn't exist LuigiL
5/2/2006 7:46:47 AM
Re: onLoadError won't run when MC doesn't exist Joseph Russavage
5/3/2006 12:30:35 AM
Thanks for the suggestions! I put the code within the onPress for teh same
reason that one puts a for loop within an if statement... I don't need the code
to waste memory or processor cycles unles one actually clicks on the button.
But OOP is new to me, so some of the ground rules are too.

You are absolutely right about the order of the code in this case. I moved my
"loadClip" statement after my listener objects and now it runs great.

Thanks for the lesson and the assistance!

~ Joseph ~
:o
AddThis Social Bookmark Button