Orbiting animation using the AS
Submited in: Flash
| Total Views: 13665
Using this thoroughly explained, detailed and quickly flash lesson, I will explain to you how to create orbiting animation using a little AS code. Let's start!
First, save the image of earth below!
Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the width of your document to 430 pixels and the height to 350 pixels. Select black as background color. Set your Flash movie's frame rate to 15 and click ok.
Call the current layer earth. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!
Choose now File > Import > Import to stage (Ctrl+R) and import the image of earth that you saved in step 1!
While the image is still selected, go to the Align Panel (Ctrl+K) and do the following:
1. Make sure that the Align/Distribute to Stage button is turned on,
2. Click on the Align horizontal center button and
3. Click the Align vertical center button.
While the image of earth is still, still selected, press F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.
While the new made Movie Clip (earth) is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip earth. See the picture below!
Create now a new layer above the layer earth and name it object. After that, using the flash tools for drawing, draw any object.
While the object is still selected, press F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.
After that, place the object on the position like it is shown on the picture below!
Select now the Selection Tool (V) and click once on the object to select it. After that, go to the AS panel (F9) and enter this code inside the actions panel:
xDistance=Math.sin(angle * Math.PI/180)*mainDistance
yDistance=Math.cos(angle * Math.PI/180)*mainDistance
Test your Movie and enjoy!