Groups | Blog | Home
all groups > flash actionscript > may 2004 >

flash actionscript : updateAfterEvent () not working?


Someink
5/6/2004 11:39:03 PM
Hi - from what I've read about [b]updateAfterEvent () [/b], it should work in a
function, but this code (which I want to use to make an mc (called sq) slide to
a set width doesn't animate, it just 'snaps' to the width 'x'. Any ideas what
I'm doing wrong? Using MX, by the way.

Cheers - C

function moveme (x)
{
do {
updateAfterEvent();
sq._width += ((2*(sq._width<x))-1);
} while (math.abs(x-sq._width)>.5)
}
egorlebowski
5/7/2004 12:17:22 AM
Hi...

updateAfterEvent doesn't really work that way...it updates the stage after an
event such as onMouseMove, but not during a loop such as you have...the entire
loop executes before the stage is refreshed, snapping the clip to the new
width...

Look into using setInterval or onEnterFrame to call your function if you want
it to animate

Here is a good explanation of updateAfterEvent:
http://www.flashguru.co.uk/000736.php

Hope this helps
Someink
5/7/2004 12:32:21 AM
Thanks for that - this seems clear, I was looking for the equivalent to
Director's 'UpdateStage' command, thought this was it - I was trying to avoid
having frame loops to show the animation, but if I have to use 'onEnterFrame'
anyway I might as well just stick to looping frames.

thanks for the site link too, very helpful!

Cheers - C
kglad
5/7/2004 3:24:00 AM
for-loops and do-while loops execute from start to end before anything is
updated on stage and execute too quickly for animation purposes. look at
setInterval() if you need more flexibility than a clipevent affords.
AddThis Social Bookmark Button