Helpful Information
 
 
Category: Flash Help
How do you make a clip move more smoothly without increasing the frame rate please?

Hello,

I have been developing this piece of code with the help of people in the forum and what I have so far is below. It makes a clip move around the screen in the opposite direction to the mouse.

It all works fine, but when the clip moves, it is jerky. Is there any way to make it move more smoothly without increasing the framerate? Increasing the framerate does not do anything on older computers with slower processers.

Can the code be altered at all to make the clip move more smoothly?

Many thanks

James

onClipEvent(Load){
//where 550 X 400 is your movie size
M_halfwidth= 550/2
M_halfheight= 400 /2
}
onClipEvent (enterFrame) {

//this will always move the peice relevant to the centre
//as it tracks every frame not just when mouse moves= no delay

_y = M_halfheight+(M_halfheight-_root._ymouse);
_x = M_halfwidth+(M_halfwidth-_root._xmouse);

//then you need to check if you have moved 2 far
//check _x at minimum and max
if (_x<=0){
_x=0;
}else if (_x>=M_halfwidth*2){
_x=M_halfwidth*2;
}

// do the same for _y
if (_y<=0){
_y=0;
}else if (_y>=M_halfheight*2){
_y=M_halfheight*2;
}


}

What do you have the framerate at now? Flash 5 is fairly fast with vector graphics and such, these days you don't really need to worry about "slower computers" with most applications unless your movie uses tons of bitmaps with alpha effects and such. On a Pentium II 400Mhz or so, which is pretty slow compared to today's P4 2.4Ghz machines, most Flash movies don't have much slowdown even at 30+ fps. A slower Pentium III at maybe 600Mhz or so can run a lot of clips at 60fps which is the maximum. Unless you specifically target your site to people who use slow Pentium I machines then I wouldn't even worry about increasing the frame rate.

If you are running at the default 12fps it's going to be hard to get anything smooth. That's a very slow framerate. When you look at a lot of Flash movies these days that seem to run very smoothly, with very fluid animations, they are probably running at 40fps or more. To make the animation smoother for that clip following the mouse, you're just going to have to make it follow the mouse slower (i.e. it's always going to be way behind it, catching up at it's own pace).










privacy (GDPR)