2 Replies Latest reply on Aug 2, 2010 7:29 AM by monty_hall

    How to animate through 5 png's

    monty_hall Level 1

      Not clear how I would do this.  But I have png's that I would like to iterate thru.  I would assume this kind of functionality would exist in flash somewhere.  My, incomplete, as3 code, is a brute force hack.

       

      [Embed("...")]

      image1

      [Embed("...")]

      image2

      [Embed("...")]

      image3

      [Embed("...")]

      image4

      images=[image1, image2, image3, image4]

      currentFrame = 0;

       

      onTimer(..) {

        how to I set the image of a flex xml component? = images[currentFrame++];

      }

       

      Any advice (especially how I created the array of images, would think there is a more direct way to place into array w/o having to creating imageX vars) appreciated.

       

      Monty

        • 1. Re: How to animate through 5 png's
          Balakrishnan V Level 3

          1. On timer, just modify the source attribute of your <mx:Image /> so as to point to a different image each time. The source attribute values (location of images) can be put in an array.

           

          2. Use a loader object to load the images. You could name your image files as image1.jpg, image2.jpg, ... so that you can put the loader.load("image"+i+".jpg") inside a loop. Handle the loader result and use the loader.content property and box it into a Bitmap object and successively push these objects into an array.

           

          Does this help ?

           

          Thanks


          balakrishnan v

          • 2. Re: How to animate through 5 png's
            monty_hall Level 1

            Animations worked great.  Thanks, I will try out your second suggestion about packing animations into an array using the loader object.