2 Replies Latest reply on Feb 15, 2007 8:09 PM by kwp

    Loading images Dynamically

    kwp
      I have seen a lot of questions and support on loading images dynamically into Flash but I am pretty rusty with my Actionscript and have not used XML. Is there some very simple actionscript code that can load various images into my flash movie from a specific directory. Or is there a good step-by-step tutorial on loading external images that does not get too bogged down in technical detail. Any help for a newbie would be appreciated.
        • 1. Loading images Dynamically
          dalewb
          This is how I do it for one jpg at a time:

          this.createEmptyMovieClip("instanceNameMC", this.getNextHighestDepth());
          var myMCLoader:MovieClipLoader = new MovieClipLoader();
          myMCLoader.loadClip(" http://www.yourURL/yourImagename.jpg", instanceNameMC);

          (hint for a local image file, change the URI to just the image name, if it is in the same dir as your swf or to "foldername/image.jpg" if it is in a subdirectory) NOTE: loadClip is only good for loading swfs, jpg, gif, and png files

          Slap that sucker in frame 1 of your timeline and it'll spit out the image you designate onto the stage at (0,0).

          Even better - put that code inside of a movie clip and put the movie clip on the _root stage (or wherever you wish). You will not be able to see it except for its tiny little circle/target-registration mark thing, but with that selected you can now move, rotate, apply animation to, and scale the whole thing. Just make sure you don't set the height or width of the empty movie clip before the content has loaded into it or the content will not show.

          Read up on all this in the Flash 8 Actionscript Bible Ch 14 or pgs 276+ You can view some of it on Amazon.com if you don't own it (but you should get it!!)
          • 2. Re: Loading images Dynamically
            kwp Level 1
            Wow. That was easy. It worked like a charm! Thanks. You saved me a ton of time.