3 Replies Latest reply on May 30, 2008 5:28 AM by DFord425

    Pass Images between modules

    DFord425 Level 1
      Is it possible to put images in an array, then access them from a different module so that i do not have to create 2 Images, i can just reference the image in the array?
        • 1. Pass Images between modules
          Bryan Dresselhaus Level 1
          For my projects I usually create a class called Resources and create static vars for the images. Then you import the Resources class in each module and use <mx:Image source="{Resources.image_avatar_archer}"/>...ect

          However, this approach may embed the images in each module, increasing its size. It might be best to have a setter function in the modules that your main application can invoke, setting the image sources from there.

          package {

          public class Resources{

          public function Resources(){}


          // ===================================================================
          // Avatar Images
          // ===================================================================

          [Embed(source="Images/Avatars/archer.jpg")]
          public static var image_avatar_archer:Class;

          [Embed(source="Images/Avatars/knight.jpg")]
          public static var image_avatar_knight:Class;

          }
          }
          • 2. Re: Pass Images between modules
            DFord425 Level 1
            Im trying to get the images dynamically so im not going to know the file names/ how many files i will have so im not sure how i can embed them. Im trying to do this so that i can save space while the application is running.
            • 3. Re: Pass Images between modules
              DFord425 Level 1
              Does anyone else have any ideas. My application scans a directory for image files, puts those into an array. Then displays the x amount on the bottom of the screen. If a user clicks on one, i want to reference the small image and display it in the middle of the screen, much bigger than the images on the bottom. The bigger image is in a different module and right now, i have it loading another image with the same path as the small image clicked. Im looking for a way to reference the small image so that i do not have to create another Image() object.
              Thanks in advance.