Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Action Script to Move Objects 1

Status
Not open for further replies.

vivasuzi

Programmer
Jun 14, 2002
183
Is there a way to write an action script to move an object? I need to move an object along a path that is created mathematically. For example, my graphic has to move along a sin wave line. The sin wave is calculated in code.

Is this even possible? I'm very new (just started today) to action scripts and I don't want to waste time if this isn't possible.

Thanx for any help! :)
 
Yes it is posible using a movie clips '_x' and '_y' Regards

David Byng

spider.gif


davidbyng@hotmail.com
 
Well ok, so it is possible... how about a little help on how to do it, or where can I find some information to get started? *Suzanne*
 
How's this?


Here's the code, it's simply attached to the "ball" which is a movieclip.

onClipEvent (load) {
count = 0;
}
onClipEvent (enterFrame) {
//horizontal position
_x = count;
//vertical position (degrees turned to radians for calculation, the rest is just centring the wave on the stage)
_y = (Math.sin(count*Math.PI/180)*100)+180;
//go to the next position
count++;
//reset once 360 degrees have been traversed
if (count>359) {
count = 0;
}
} Slainte

 
That link doesn't seem to do anything. *Suzanne*
 
Nice code.
The link does work - wondering wether it wqsa published in MX?
Ben
 
I clicked the link and the pop up window just sits there loading.. after it gets to 50% it seems to freeze. If it does work it's very slow. *Suzanne*
 
I'm using Windows 2000 on a compaq. But it might be b/c I'm at work. I'll wait til I get home and try it out. *Suzanne*
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top