1 Reply Latest reply on Jul 23, 2009 10:36 AM by Rothrock

    If JPeg Exists

    railanc4309

      Good morning all,

       

      I'm having sooo much difficulty with something that in theory sounds really easy!!!

       

      I have 4 thumbnail MC clips on my stage.

      Each of these thumbnails are populated dynamically to get thumbnails of a product from our server.

       

      In the majority of cases, there are 4 pictures, so my thumbnails are populated OK.

       

      However, in some cases, there are not 4 pictures, so my MC clips might only show 2 or 3 thumbnails.

      In a separate layer, I have some transparent Buttons, which act as links to larger images of each of the thumbnails.

       

      My code for the buttons is:

       

       

      on (release) {
      image = "http://www.--------URL---------/images/products/zoomable/image1.jpg";
      mcl.loadClip("http://www.--------URL---------/flash/zoom.swf", targetMc);
      }

       

       

      What I want to do is check whether the image exists. If it does, then do the on release code above, if not, then do nothing.

       

      Sounds simple, but being fairly new to AS 2.0, i'm having a great deal of difficulty trying to make sense of someone elses code I found earlier...

      A fresh pair of eyes would be greatly appreciated!!!

       

      Thanks in advance,

       

      Rachael

        • 1. Re: If JPeg Exists
          Rothrock Level 5

          As far as I know there is no simple/useful way to check if it exists and then load it if it does.

           

          What you have to do is try to load it and if it is successful you are good and if there is an error do something else.

           

          So the mcl is certainly an instance of the MovieClipLoader class which has both onLoadStart, onLoadProgress, and onLoadInit events (for when you are getting your file) and onLoadError (for when you aren't). So I suggest you read up on the the MCL class and what it has to offer. Then post back if you have questions about it.

           

          Also is it is pretty ridiculous to be using newer coding techniques like the MovieClipLoader class and to also still be using on(event) type syntax. Here is a great article about why you shouldn't use that outdated technique anymore:

           

          http://www.quip.net/blog/2006/flash/museum-pieces-on-and-onclipevent