all groups > flash actionscript > may 2004 >
You're in the

flash actionscript

group:

Creating Dynamic Animation in Action Script


Creating Dynamic Animation in Action Script AJH16
5/27/2004 10:24:27 PM
flash actionscript: I need to generate a dynamic animation when a button is clicked. Essentially,
I have an image that is located in a movie clip, a joystick that moves that
image around, and I have a button that when pressed will remember the current
position of the image. The trick is that I then want the user to be able to
move the image around and when they push the button again I want it to animate
(over say 10 frames) going back to the memorized position. I am currently
"memorizing" the position by storing the _x and _y values of the movie clip and
then I can generate the needed change simply using the equation _xchange=(
_xold - _x )/10 and the same for y and then moving by that distance each step.
The problem is that I have no context in which I can seem to make it repeat the
animation. If I try using a while loop, it doesn't refresh until after the
while loop is finished, and I don't know of any event handler that I can use.
(I had been using onClipEvent(enterframe) for some similar things, but that
doesn't work in this case because they can exit the boundary of the movie clip.
Any advice would be appreciated.
Re: Creating Dynamic Animation in Action Script BarneyK
5/28/2004 12:20:43 PM
You want to use setInterval for this together with updateAfterEvent.
setInterval can be used to invoke a function at regular intervals defined by
the INTERVAL parameter you pass in. You can use this to call a function that
increases the x and y values of your mc by the xChange and yChange values you
calculated. You should also call updateAfterEvent after you create the new x
and y properties of your mc which refreshes the screen - the screen will
normally only be refreshed when a new frame is entered.
hth
AddThis Social Bookmark Button