6 Replies Latest reply on Jan 3, 2008 4:52 PM by Newsgroup_User

    Animating a dynamically loaded image

    ooba Level 1
      I am getting back into flash after several years. I have a small project where I am loading in external images into MC using .loadClip()

      such as in the example code.

      The question is how can I animate the image that I have loaded dynamically to move from point A to point B a distance of Xpixels over a period of 5 frames where the flash setting is 18fps?

      Not really looking for anyone to do the work for me just point me in the correct direction as what I have been putting in place via use of setInterval() is rather choppy and not clean looking.
        • 1. Re: Animating a dynamically loaded image
          kglad Adobe Community Professional & MVP
          use an onLoadInit() method of your listener to start your animation. you can use a loop (tween class, onEnterFrame or setInterval() ) to animate the movement.
          • 2. Re: Animating a dynamically loaded image
            ooba Level 1
            Not familiar with the tween class or use of the onEnterFrame. But will look into this. I kind of figured you would respond kglad. You seem to be all over the questions in this forum.
            Thanks.
            • 3. Re: Animating a dynamically loaded image
              kglad Adobe Community Professional & MVP
              the tween class is very easy to use. just check the help docs for an example and don't forget to import the needed class(es) - also shown in the help files.
              • 4. Re: Animating a dynamically loaded image
                ooba Level 1
                Thank you Klgad. That was a whole lot easier than me trying to build that functionality.

                just for clarity for anyone else.

                [code]
                import mx.transitions.Tween;

                var myTween:Tween;
                var myMCL:MovieClipLoader = new MovieClipLoader();

                var myListener:Object = new Object();
                myMCL.addListener(myListener);

                var container_mc:MovieClip = this.createEmptyMovieClip("container_mc", this.getNextHighestDepth());

                myMCL.loadClip("image.jpg", container_mc);

                myListener.onLoadComplete = function(mc:MovieClip) {
                // Tween( obj:Object, prop:String, func:Function, begin:Number, finish:Number, duration:Number, useSeconds:Boolean(false == frames )
                myTween =
                new Tween(
                container_mc,
                "_x",
                mx.transitions.easing.None.easeNone,
                startPos,
                endPos,
                5,
                false
                );
                }

                This will load an external image and then move the container from pointA to pointB.
                • 5. Re: Animating a dynamically loaded image
                  kglad Adobe Community Professional & MVP
                  you're welcome.

                  p.s. you should use onLoadComplete instead of onLoadInit. i don't think you'll have a problem with your current code, but you will if you continue to favor onLoadComplete over onLoadInit.
                  • 6. Re: Animating a dynamically loaded image
                    Level 7
                    you're welcome.

                    p.s. you should use onLoadComplete instead of onLoadInit. i don't think
                    you'll have a problem with your current code, but you will if you continue to
                    favor onLoadComplete over onLoadInit.