Frame rate and speed

ok so usually when I want to move an object at a consistent speed no matter what the frame rate, I will use this equation:

ActionScript Code:
[LEFT][COLOR=#000000]**var**[/COLOR] timeDiff:[COLOR=#0000FF]Number[/COLOR];

[COLOR=#000000]var[/COLOR] lastTime:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#0000FF]getTimer[/COLOR]COLOR=#000000[/COLOR];

[COLOR=#0000FF]public[/COLOR] [COLOR=#000000]function[/COLOR] animationLoopCOLOR=#000000[/COLOR][COLOR=#000000]{[/COLOR]

timeDiff=[COLOR=#0000FF]getTimer[/COLOR][COLOR=#000000]([/COLOR][COLOR=#000000])[/COLOR] - lastTime;
lastTime+= timeDiff;

myObject.[COLOR=#000080]x[/COLOR] += [COLOR=#000080]10[/COLOR] * timeDiff / [COLOR=#000080]1000[/COLOR];

[COLOR=#000000]}[/COLOR]
[/LEFT]

however I have an object (black hole) that when active sucks all other object in towards it, furthermore when the objects gravitate toward the black hole, they rotate at an angle, here is the code for that:

//for object gravitating to the black hole
ActionScript Code:
[LEFT][COLOR=#000000]var[/COLOR] dx:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]x[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]x[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]var[/COLOR] dy:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]y[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]y[/COLOR][COLOR=#000000])[/COLOR];
[COLOR=#000000]var[/COLOR] radian:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]atan2[/COLOR]COLOR=#000000[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]rotation[/COLOR] = radian * [COLOR=#000080]180[/COLOR]/[COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]PI[/COLOR];
[COLOR=#000000]var[/COLOR] easeX:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]x[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]x[/COLOR][COLOR=#000000])[/COLOR] * .[COLOR=#000080]01[/COLOR];
[COLOR=#000000]var[/COLOR] easeY:[COLOR=#0000FF]Number[/COLOR] = [COLOR=#000000]([/COLOR]theBlackHole.[COLOR=#000080]y[/COLOR] - [COLOR=#0000FF]this[/COLOR].[COLOR=#000080]y[/COLOR][COLOR=#000000])[/COLOR] * .[COLOR=#000080]01[/COLOR];
gravity+=.[COLOR=#000080]006[/COLOR];
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]x[/COLOR] += [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]cos[/COLOR]COLOR=#000000[/COLOR] * gravity;
[COLOR=#0000FF]this[/COLOR].[COLOR=#000080]y[/COLOR] += [COLOR=#0000FF]Math[/COLOR].[COLOR=#0000FF]sin[/COLOR]COLOR=#000000[/COLOR] * gravity
[/LEFT]

now my problem is the speed of the object isn’t consistent through frame rates, does anyone know what I could do to make this possible

Have you tried animating using the enter frame event rather than using timer?

You should use an enterFrame event but base your animation on getTimer().

Just using enterFrame will give you a frame rate-based animation. This will go faster or slower depending on your frame rate. You can use a Timer, which is time-based, but Timers are not consistent and are influenced by the frame rate (changing the frame rate can cause your Timer to run at different intervals). Additionally, Timer timing can be delayed by other factors which could throw off your animations or anything else relying on specific timing.

The best solution is using the system time through either getTimer() or the Date object, and animating your objects based on the time elapsed every frame. Using the enterFrame event makes sure that your objects are being drawn at the refresh rate of the player and using the time you can make sure that the animations are time based and not frame based - this all irrespective of the frame rate (though slower frame rates will, obviously, not show as many frames for an animation).

What you have above is not far off from this kind of implementation. You just need a startTime (= getTimer()) from when an animation started and a duration. Then, every frame you get the difference from the currentTime (getTimer()) and the difference over the duration is your progress (progress = difference/duration). Just be sure to stop the animation once the difference is greater than or equal to the duration.

yeah, but I prefer to work with Timers rather than enter_frames. With timers, you always have more control over your motion

[QUOTE=RebuiltJorge;2332105]yeah, but I prefer to work with Timers rather than enter_frames. With timers, you always have more control over your motion[/QUOTE]

In what way?

Weird Senocular, I orignally posted this response to Groady

“yeah, but I prefer to work with Timers rather than enter_frames. With timers, you always have more control over your motion”

However, I had not yet seen you post yet. Thanks for that, it makes perfect sense now, good job!