2 Replies Latest reply on Apr 6, 2007 10:28 AM by chopTheWood

    loaded .jpg.......NOT

    chopTheWood Level 1
      Here is my script for loading a .jpg into a movieClip called "placeHolder". But what if the image is not available to be loaded? How do I catch the error and give a message to the user? I tried accessing the varaible pBar.loaded and percentLoaded bu that didn't work.



      setProperty(pBar, _visible, true);
      myLoader = new MovieClipLoader();
      myListener = new Object();
      myListener.onLoadStart = function(clip) {
      pBar.label = "Loading Image...: ";
      };
      myListener.onLoadProgress = function(clip, bytesLoaded, bytesTotal) {
      var percentLoaded = int(100*(bytesLoaded/bytesTotal));
      pBar.setProgress(bytesLoaded, bytesTotal);
      };
      myLoader.addListener(myListener);
      myLoader.loadClip(theImagePath, _root.placeHolder);
      myListener.onLoadComplete = function(clip) {
      pBar.label = "Load Complete: ";
      setProperty(pBar, _visible, false);
      };
        • 1. Re: loaded .jpg.......NOT
          Rothrock Level 5
          What do you mean, you tried accessing the variable pBar.loaded and it didn't work?

          In any event that doesn't matter. You have managed to find the onLoadStart, onLoadProgress, and onLoadComplete events of the MovieClipLoader. I suggest you keep reading the entries for that class until you get to the onLoadError event!

          Also you might want to use the onLoadInit instead of the onLoadComplete. For what you have so far that will work fine as it is. But if you want to measure the _width/_height of the loaded clip or things like that you will need onLoadInit.
          • 2. Re: loaded .jpg.......NOT
            chopTheWood Level 1
            Yes, this addition solved the problem:

            myListener.onLoadError = function(placeHolder:MovieClip, errorCode:String, httpStatus:Number) {
            if (errorCode == "URLNotFound") {
            trace("This image couldn't be found.");
            }
            }