6 Replies Latest reply on Sep 15, 2006 10:46 AM by TimSymons

    scope problem

    sbryner Level 1
      Hello,

      I've created:

      createEmptyMovieClip("thumbLoader_mc",1);
      // an empty movieClip

      I then created

      var mc = thumbLoader_mc.createEmptyMovieClip("new"+i,i);
      // an empty mc inside the thumbLoader_mc

      I then attached a movieClip named "thumbContainer" to each var mc

      mc.attachMovie("thumbContainer", "new"+i,i, {_x:xPosThumb, _y:yPosThumb, _width:THUMBW, _height:THUMBH});

      Now I have a Loader component named "thumbLoader" inside the "thumbContainer" movieClip.

      I want to use content path to place images inside this "thumbLoader", but how?

      I've tried this:

      thumbLoader["new"+i].contentPath = PICPATH+"2.gif"; // PICPATH ="Flash Test /" a folder that the images are in

      and don't know where else to look to possibly solve this problem.

      There are images that load from an array:
      searchResult .pic

      I've also tired:

      mc["new"+i].thumbLoader.contentPath= searchResult
      . pic;

      but I'm sure it is a scoping problem can anybody help?
      thanks,

      sky
        • 1. Re: scope problem
          TimSymons Level 1
          I gather you just want to load external images into a series of movieclips. You cannot just assign a path to a movieclip and have it load the image. Take a look at the MovieClipLoader class. Here is part of the example from the help files:

          var container:MovieClip = createEmptyMovieClip("container", getNextHighestDepth());
          var mcLoader:MovieClipLoader = new MovieClipLoader();
          mcLoader.loadClip("YourImage.jpg", container);

          The MovieClipLoader class will handle the loading for you.

          Tim
          • 2. Re: scope problem
            sbryner Level 1
            Actually, I'd like to load a bunch of images into a loader component inside a movieClip. The movieClip also contains dynamic text fields as
            well.

            Is it better to try to load the images an "image_mc" inside the movieClip instead of loading into loader component inside the movieClip?

            sky
            • 3. Re: scope problem
              sbryner Level 1
              think I got it.

              this seemed to start working for me...

              mc["new"+i].thumbLoader.loadMovie(PICPATH+i+".gif",getNextHighestDepth);
              • 4. Re: scope problem
                TimSymons Level 1
                Sure, you can do that.

                You created the container already and all of the movieclips that you wanted to hold the images, so just use that path in the MovieClipLoader's loadClip() function.

                Couple of things to remember. If you only use 1 MovieClipLoader then you will have to wait for each clip to load before loading the next. If you want to load them at the same time, you could create a class around the MovieClipLoader, then pass the class instance the filename and have it perform the loading using the MovieClipLoader.

                I did this for an image viewer with thumbnails. I have attached the code below. It is not the prettiest code but hopefully will give you an idea.

                Tim

                • 5. Re: scope problem
                  sbryner Level 1
                  do you have this online? can I see it?

                  question. I've got the images loaded into a loader.... can I resize them to fit inside the loader? they are larger than the loader component is.

                  this code is complicated for my young flash mind to wrap around. though it appears to be what I'm trying to accomplish.
                  • 6. Re: scope problem
                    TimSymons Level 1
                    Yes, I do have it online but it is behind a corporate firewall so it is not viewable.

                    As far as resizing, you should be able to set the size to what ever you want. The code I posted will load the images at their full size, I then resize them once they have been fully loaded. Then the script also allows you to click on the image and it will then animate up to the full size of the image (or 400x400) which ever is smaller. The animation, is the Tween and uses the Tween fuction by Joey Lott (www.person13.com).

                    To get this to work you have to create 2 movieclips. The first is a container to which the code above is attached as a class. The second movieclip is placed inside the first and given the instance name "imageClip".

                    Then to load an image you would use:

                    mcContainer.LoadImage("path to image here");

                    where mcContainer is whatever the instance name of the first movieclip is.

                    In the code I set the sizes in the 2 objects thumbSize and regularSize. The regularSize is the 400x400 image and the thumbSize is the 50x50 image.

                    I will try to get this to a site that is not behind a firewall but I don't have a website so it may take a little time.

                    Tim