1 Reply Latest reply on May 1, 2006 3:43 PM by shyaway

    onLoadError won't run when MC doesn't exist

      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 looks like this:

      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);

      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.
        • 1. onLoadError won't run when MC doesn't exist
          shyaway Level 1
          isn't there another thread for this already or am i hallucinating? (i shouldn't be pulling all nighter too often)

          anyhow, your listener is inside an onRelease, so, it could be that it doesn't get compiled in order properly. try putting your listener before your loadClip command and see what happen.

          Also, listeners shouldn't be wrapped in an event like that, it just look wrong, but as long as it works. I hadn't actually tested it, so i can't confirm is that is actually working.

          edit: the second param for loadClip should be of type MovieClip, not string. In that case, "_root" without the quotes. Flash likes to dump stuff into _root when a param is passed incorrectly, so, that might be the case...