4 Replies Latest reply on Jul 21, 2006 12:00 PM by Gregory_Berry

    Embed images in one MovieClip, use in another?

    Gregory_Berry
      Hi everyone--

      Is it possible to embed images (jpgs) in one MovieClip, then load that SWF into another MovieClip and use those images in the loader? We are trying to avoid reloading an image each time we need it, but still load them dynamically. We'd like to do this: (We're using Flex, but this is really an AS question I think, about accessing resources from one SWF in another SWF). This example is in Flex, but the real work, I expect, is in AS. If you can tell me how to do it in AS, I can get it working in flex.)

      Container.swf:
      <mx:Application>
      <mx:Script>
      [Embed(source="images/myimage.jpg")]
      public var img: String;
      </mx:Script>
      </mx:Application>

      Then, load that SWF and use its embedded image:

      Loader.swf:
      <mx:Application>
      <mx:Loader id="container" source="Container.swf" />
      <mx:HBox>
      <mx:Image id="the_image" source="container.content.img" />
      </mx:HBox>
      </mx:Application>

      It looks like this should work, and the "resource" string is properly being passed to the_image (something like __Resource.43234564.myimage_jpg) but it cannot actually load; we get a broken image instead.

      I'm guessing I somehow need to register the object library of the Container.swf with my Loader.swf? How?

      Or, is this whole enterprise impossible?

      Thank you!

      Greg

        • 1. Re: Embed images in one MovieClip, use in another?
          micahkoga
          I'm not sure what you mean by "use them in the loader" because if you embed images into the swf, then when you load that container, you are essentially downloading all the images in the container at the same time.

          If that's not a problem and if there are multiple images embedded, then each image would have to be in it's own movieclip for this to work.
          I'm assuming you're loading container.swf into loader.swf.
          You could then access them by: loader.container.img1_mc...img2_mc...etc
          • 2. Re: Embed images in one MovieClip, use in another?
            Jim_Esteban Level 1
            The short answer is yes.
            • 3. Embed images in one MovieClip, use in another?
              Gregory_Berry Level 1
              To which question? Since question1==true (is it possible) if and only if question2==false (is it impossible) you can understand, perhaps, that your reply was less than helpful. Thanks for wasting everyone's time, though; it's appreciated.

              • 4. Re: Embed images in one MovieClip, use in another?
                Gregory_Berry Level 1
                Thank you for your reply. You say:

                quote:

                Originally posted by: micahkoga
                I'm not sure what you mean by "use them in the loader" because if you embed images into the swf, then when you load that container, you are essentially downloading all the images in the container at the same time.


                Yes, this is exactly what we want. We want to use those images as the source for components in the Loader.


                quote:

                If that's not a problem and if there are multiple images embedded, then each image would have to be in it's own movieclip for this to work.
                I'm assuming you're loading container.swf into loader.swf.
                You could then access them by: loader.container.img1_mc...img2_mc...etc


                ....maybe this is more of a flex question, because we need to use the container.img1 images as the content of a Flex Image tag. I think the real confusion is what exactly "is" an "embedded" image--is it in the mc's link library? Or something else? This whole part of flash/as/flex is very vague and mysterious, and it's next to impossible to find documentation or examples.

                Thanks again.