Three-dimensional effect of flash with pure script

Source: Internet
Author: User
Tags copy cos sin
Script

Copy the following code into the action panel in Flash!

Declaring parameters and starting values
var n = 0;
Initial coordinates
a_x = STAGE.WIDTH/2;
a_y = STAGE.HEIGHT/2;
Half-week coefficient
var p = math.pi/180;
Create an empty movie clip MC
_root.createemptymovieclip ("MC",-1);
Draw a semicircle on the MC, in which a parameter equation is used, the parameter of the circle is 150 pixels, the size is drawn from 90 degrees, it is a vertical semicircle.
With (_ROOT.MC) {
LineStyle (1, 0x999900, 100);
For (i=0 i<180; i++) {
MoveTo (150*math.cos (90+i) *p), 150*math.sin ((90+i) *p));
LineTo (150*math.cos (91+i) *p), 150*math.sin ((91+i) *p));
}
}
Set the coordinates of a circle
_root["mc"]._x = a_x;
_root["mc"]._y = a_y;
Copy a movie clip and reverse the movie clip, forming an entire circle with the previous semicircle
Duplicatemovieclip ("MC", "MC" +0, 0);
_root["mc0"]._x = a_x;
_root["mc0"]._y = a_y;
This is the reverse semicircle.
_root["mc0"]._xscale =-100;
Copy 12 semicircle
For (I=1 i<=12; i++) {
Duplicatemovieclip ("MC", "MC" +i, I);
Execute a script on each movie clip
_root["MC" +i].onenterframe = function () {
Gets the argument for the name of the movie clip instance, where it represents the two characters Fu Qi from the third character, which is a number
i = This._name.substr (2, 2);
The coordinates of the movie clip
this._x = a_x;
this._y = a_y;
The rotation of the movie clip, here, in 60-degree rotation
This._rotation = Math.Round ((i-1)/6) *60;
Zoom for movie Clips
This._xscale = 100*math.cos (((i-1)%6) *60+n);
Transparency of movie clips
This._alpha = 10+ (1-math.cos ((i%6) *60+n) *p)) *45;
/* parameter increment, this parameter can also be changed dynamically by the coordinates of the mouse
Like n+=_root._xmouse/1000, we can hide n+=.2 look at the effect
Here I hide the mouse effect * *
n =. 2;
n + = (stage.width/2-_root._xmouse)/1000;
};
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.