Flash highlights examples of making rotating flowers

Source: Internet
Author: User
Tags array cos eval sin
The final rotation effect is as follows:

http://www.flash8.net/bbs/UploadFile/2005-4/2005416211918814.swf


Create first Ellipse
Createemptymovieclip ("L0", 0);
With (L0) {
Beginfill (0xff0099, 50);//Fill Color
MoveTo (30, 0);
for (var i = 0; i<=2*math.pi; i + = math.pi/180) {
LineTo (30*math.cos (i), 50*math.sin (i));
}
Endfill ()//End Fill
}
r = 0;//variable initialization
Onenterframe = function () {
R + + math.pi/60;
Create an empty array
x = new Array ();
y = new Array ();
Du = new Array ();
Copy First Ellipse
for (var i = 1; i<5; i++) {
L0.duplicatemovieclip ("L" +i, I);
}
Set the motion and rotation of the ellipse
for (var i = 0; i<5; i++) {
Eval ("L" +i). _x = 273+50*math.cos (2*math.pi/5*i+r);
Eval ("L" +i). _y = 200+50*math.sin (2*math.pi/5*i+r);
Assigning values to an array element
X[i] =-math.cos (2*math.pi/5*i+r);
Y[i] =-math.sin (2*math.pi/5*i+r);
Du[i] = Math.atan (y[i]/x[i]) *180/math.pi;
Set the angle of rotation of the ellipse
Eval ("L" +i). _rotation = x[i]>0? 90+du[i]: du[i]-90;
}
};
Play your rich imagination, wonderful effect waiting for you!

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.