Flasher Archive
[Previous] [Next] - [Index] [Thread Index] - [Previous in Thread] [Next in Thread]
Subject: | FLASH: Move an object in a circle without tweening |
From: | John Croteau |
Date: | Wed, 27 Oct 1999 21:30:51 +0100 |
Hi all,
I just answered a question on how to use Trig functions (on the MM
newsgroup) and thought you might want to see the code for moving an
object in a circle using our Plug and play Trig function. You do NOT
need to be a programmer to use this.
You do need the latest version of the Trig Plug and Play though.
http://www.FlashBible.com/Members/ActionScript/PlugNPlay/Trig.htm
If you have seen our new demo in the Preloader Plug and Play you will
see the use of Sine and Cosine to move the arrows at an angle using
properties and not Tweens. Don't forget to click on the Sun.
http://www.FlashBible.com/Members/ActionScript/PlugNPlay/Preloader.htm
I have 2 Tutorials coming out soon showing both moving an object at an
angle and moving one in a circular motion. I have included an advance
copy of the script below for moving a movie clip symbol in a circle.
The formula we use for a point on a circle are
x = Xcenter + (Radius * Sine(angle) )
y = Ycenter + (Radius * Cosine(angle) )
* is used in Flash for multiplication
The script below will rotate a movie clip MC in a circle.
Xpos and Ypos are the x and y offsets.
Answer is the result (sine or cosine) returned from the Trig Call
functions.
Speed is the Angle difference checked (5 would start do 5, 10, 15, 20
etc.)
R is radius of circle path.
You need to set 4 variables before the action loop such as:
Set Variable: "Xpos" = 200
Set Variable: "Ypos" = 200
Set Variable: "R" = "100"
Set Variable: "Speed" = "5"
You need 2 frames for the action - the first below and one following it
that loops back to the first.
Set Variable: "Angle" = Angle + Speed
If (Angle > 360 )
Set Variable: "Angle" = Angle - 360
End If
Call ("Trig:Sin")
Set Property ("/mc", X Position) = Xpos + (R * Answer)
Call ("Trig:Cos")
Set Property ("/mc", Y Position) = Ypos - (R * Answer)
--
Coming Soon Flash 4 Web Animation F/X and Design
http://www.amazon.com/exec/obidos/ASIN/1576105555/flashcentral
----------- -----------------------
John Croteau croteauerols [dot] com (mailto:croteauerols [dot] com)
------------- -------------------------
FlashTek (Advanced Websites with Flash) http://www.FlashTek.com/
Flash Bible (Fast track to good Flash) http://www.FlashBible.com/
Flash Central(The Universe Starts Here) http://www.FlashCentral.com/
The Flash Tech Resource (Tech Notes) http://www.FlashCentral.com/tech/
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
flasher is generously supported by...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Streaming Media WEST '99 Conference & Exhibition
"The Worlds largest Internet Audio & Video Event"
December 7 - 9, San Jose Convention Center, California
Reserve your space today at http://www.streamingmedia.com
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To unsubscribe or change your list settings go to
http://www.chinwag.com/flasher or email helpchinwag [dot] com
[Previous] [Next] - [Index] [Thread Index] - [Next in Thread] [Previous in Thread]