2 Replies Latest reply on Sep 3, 2008 2:58 AM by NSurveyor

    a simple query

    paramp
      Hi,
      I am a newbie working with flash. Wanted to know a good way of introducing delays in an animation.

      My program consists of a tight loop which needs to run continuously to update the position of certain objects on
      the screen. In order to make the animation slower, I have made 7 frames and copied the code to each frame.

      The problem here is that if I need to make a change to the logic, I need to copy it to each frame.

      any suggestions?
      Param
        • 1. Re: a simple query
          JohnWalsh2011
          You should research how to Ease your Animation with a tween if your animation is merely reducing its speed and not stopping.

          The AS2.0 Language Reference provides some useful examples, search for this sentence 'Using the Tween class'.
          • 2. Re: a simple query
            NSurveyor Level 2
            Hey,

            One way of being able to reuse code over and over again without having to type it out would be to stick all the code in a function and call the function several times. For example, if you had:

            bowl._x += 10;
            bowl._y -= 20;

            You could modify that to:

            function moveBowl(){
            bowl._x += 10;
            bowl._y -= 20;
            }

            And then on each frame you could have:

            moveBowl();

            In your case though, if you wanted to run a particular segment of code repeatedly at frame rate, you could use the built-in event handler for the enterFrame event. Basically, every movieclip has this event, which is evoked at a rate equal to the frame rate (fps). And so, you would use:

            this.onEnterFrame = function(){
            bowl._x += 10;
            bowl._y -= 20;
            }

            But then again, I might have missed the point you were trying to make entirely. Could you explain the set-up in more detail?