This tutorial focuses on code writing, version as 3.0. As long as the production of a rotating 3D ball, the production of graphics components do not explain, please refer to the tutorial.
Include "Math2.as"
Picture container
var menu:sprite=new Sprite ();
Make an icon move
menu.x = 300;
MENU.Y = 200;
Registering event Listeners
Menu.addeventlistener (Event.enter_frame,movemenu);
This.addchild (menu);
The Intercept of the ellipse on the X and Y axes
var disx:number = 200;
var disy:number = 10;
Rotational speed
var speed:number = 0;
Initmenu (5);
function Initmenu (n:int) {
for (Var i:int i
var mc:movieclip = new Iconmenu ();
Zoom Out icon
Mc.scalex = Mc.scaley =. 5;
Menu.addchild (MC);
}
}
Event Listener Functions
function Movemenu (e:event): void {
Get Number of icons
var iconcount:int = Menu.numchildren;
Defining arrays
var deptharray:array = new Array ();
Split the 360 degrees.
var angle:number = 360/iconcount;
for (var z:int; z
Get icon based on depth
var mc:movieclip = Menu.getchildat (z);
Jump to different frames to display a different icon
Mc.gotoandstop (z+1);
Set the location of the icon
mc.x = cosd (speed + angle*z) * DISX;
MC.Y = SinD (speed + angle*z) * DISY;
SetProp (MC, "Alpha");
SetProp (MC, "ScaleX",. 2,.7);
SetProp (MC, "ScaleY",. 2,.7);
Save icon to array
DEPTHARRAY[Z] = MC;
}
To reset the depth of an icon
Arrange (Deptharray);
Speed + 2;
}
function Arrange (Deptharray:array): void {
Sort by y-coordinate
Deptharray.sorton ("Y", array.numeric);
var i:int = deptharray.length;
while (i--) {
Menu.setchildindex (Deptharray[i], i);
}
}
function SetProp (Mc:movieclip,prop:string,n1:number =. 5, N2:number = 1): void {
Mc[prop] = ((mc.y + 2 * disy)/disy-1)/2 * (N2-N1) + N1;
}
5, new. As document, save name: Math2.as (this document is for trigonometric function calculation)
Angle Turn radians
function Angletoradian (angle:number): number
{
Return angle* (math.pi/180);
}
radians Turn angle
function Radiantoangle (radian:number): number
{
Return radian* (180/MATH.PI);
}
To calculate a sine value
function SinD (angle:number): number
{
Return Math.sin (Angletoradian (angle));
}
To calculate the cosine value
function Cosd (angle:number): number
{
Return Math.Cos (Angletoradian (angle));
}
Calculate anyway Tangent
function atan2d (Y:number, X:number): number
{
Return Radiantoangle (math.atan2 (y, x));
}
Save the FLA document in the same directory as the math2.as document and test it.