Flash 3d Effect Wonderful example--mouse 3D sensor

Source: Internet
Author: User
Tags cos eval scalar sin
Induction | Mouse flash in the field of 3D applications is very broad, flash can be very easy to make some wonderful 3D special effects, and many effects can respond to the mouse action, this example is a mouse 3D induction effect, by moving the mouse, you can affect the film in the 3D Ball, the final effect as shown below :

Animation effect:



source File Download >>>>>>


   specific production steps:

1. Start Flash, create a new movie, set the stage size of the movie to 250px*250px (in pixels), and set the background color of the movie to Black.

2. Create a new movie clip symbol, named Ball, after entering the editing area of the component, draw a positive circle with the Ellipse tool, and then open the Color mixer panel, set the fill type to a radial gradient in the panel, and set the color below the left and right two color blocks, as shown in Figure 1:



Figure 1 Setting the fill color

The RGB color code for the left color block is (103,152,116), the RGB color code for the right color block is (0,0,0), and the effect of the ball fill is as shown in Figure 2:



Fig. 2 The ball after filling the color

3. Create a new movie clip symbol, named Point, after entering the editing area of the component, drag the component ball from the library to the edit area, and then set the instance name in the property panel to Blur, as shown in Figure 3;



Figure 3 Setting the instance name for the ball

4. Or create a new movie clip symbol, named Balls, after entering the component's editing area, rename the movie default layer to point, and then drag the symbol point to the edit area, and set its instance name to point in the property panel, as shown in Figure 4;



Figure 4 Setting the instance name point

Create a new layer action on the above to set the action script to control the movie.

Add the following action to frame 1th:

X1 = "0";
Y1 = "0";

Z1 = "50";

x2 = "0";

y2 = "0";

z2 = "-50";

x3 = ". 1";

Y3 = ". 1";

Z3 = ". 1";

x4 = "0";

Y4 = "0";

Z4 = "-100";

x5 = "-50";

Y5 = "-50";

Z5 = "50";

x6 = "50";

Y6 = "-50";

Z6 = "50";

X7 = "50";

Y7 = "50";

Z7 = "50";

x8 = "-50";

Y8 = "50";

Z8 = "50";

D = "900";

Z0 = "1000";

i = "1";

while (number (i) <9) {

Duplicatemovieclip ("point", "point" add I, 20-(i*2));

Set ("Zsort" add I, I);

i = number (i) +1;

}

Add the following action to frame 2nd:

yangle = Int (/:yangle);

xangle = Int (/:xangle);

i = "1";

while (number (i) <9) {

Cosyangle = eval ("/:cos" add Yangle);

Sinyangle = eval ("/:sin" add Yangle);

Cosxangle = eval ("/:cos" add Xangle);

Sinxangle = eval ("/:sin" add Xangle);

Zpos = eval ("z" add i);

Xpos = eval ("x" Add I);

ypos = eval ("y" add i);

Tempz = ((eval ("z" Add i)) * cosyangle)-(eval ("x" Add i) * sinyangle);

Set ("X" Add I, Number ((Zpos*sinyangle)) +number ((Xpos*cosyangle));

Set ("Z" Add I, Number (((ypos) *sinxangle)) +number ((Tempz*cosxangle)));

Set ("Y" Add I, ((ypos) *cosxangle)-(tempz*sinxangle));

scalar = 1/(((eval ("z" Add i)/d) +1);

Set ("XP" Add I, ((eval ("x" add i) * scalar) + 00));

Set ("YP" Add I, ((eval ("Y" add i) * scalar) + 00);

Set ("Unseen" add I, true);

i = number (i) +1;

}

n = "2";

while ((number (n) <9)) {

i = 8;

dummy = "Nada";

while (number (i) >=number (n)) {

if (eval ("Z" Add eval ("Zsort" Add (i-1)) > eval ("z" Add eval ("Zsort" add i)) {

Dummy = eval ("Zsort" Add (i-1));

Set ("Zsort" Add (i-1), eval ("Zsort" add i));

Set ("Zsort" add I, dummy);

}

i = i-1;

}

if (Dummy eq "Nada") {

n = 9;

}

n = number (n) +1;

}

i = "1";

while (number (i) <9) {

/:blur = Int (eval ("Z" Add eval ("Zsort" add i))/5);

Telltarget ("point" add I add "/blur") {

gotoAndStop (/:blur);

}

SetProperty ("point" add I, _xscale-((eval ("Z" Add eval ("Zsort" add i)))/5);

SetProperty ("point" add I, _yscale-((eval ("Z" Add eval ("Zsort" add i)))/5);

SetProperty ("point" add I, _x, eval ("XP" Add eval ("Zsort" add i));

SetProperty ("point" add I, _y, eval ("YP" Add eval ("Zsort" add i));

i = number (i) +1;

}

Add the following action to frame 3rd:

gotoAndPlay (2);

The last timeline is shown in Figure 5:



Figure 5 Timeline window for symbol balls

5. Because the film also needs to use the mouse to control the ball, we can use the Stealth button to achieve this. Create a new button symbol named YXBTN, after entering the editing area of the component, only draw a graphic in the hit frame, the shape can be free. And then create a new movie clip symbol named INV , after you enter the editing area of the component, drag the symbol yxbtn to the edit area, then extend the layer Layer1 to frame 2nd, and then create a new layer on top, and add the following action on frame 1th:

xoffset = Int (Xoldpos-getproperty ("/inv", _x));
yoffset = Int (GetProperty ("/inv", _y)-yoldpos);

if ((number (xoffset) = = 0) and (number (yoffset) = = 0)) or (not over)) {

/:xangle = (/:xangle-(/:XANGLE/20));

/:yangle = (/:yangle-(/:YANGLE/20));

} else {

/:xangle = Yoffset;

/:yangle = Xoffset;

}

if ((Number (/:xangle) >40)) {

/:xangle = "40";

else if ((/:xangle)

/:xangle = "-40";

}

if ((Number (/:yangle) >40)) {

/:yangle = "40";

else if ((/:yangle)

/:yangle = "-40";

}

Xoldpos = GetProperty ("/inv", _x);

Yoldpos = GetProperty ("/inv", _y);

Add the following action on frame 2nd:

gotoAndPlay (1);

The last workspace is shown in Figure 6;



Figure 6 Workspace Status

6. Finally back to the main scene, add three layers, named Initialize, inv and balls, from top to bottom, insert a keyframe in layer inv and balls, and then drag components Inv and balls from the gallery into Layer Inv and layer balls, respectively. , and set its instance name inv and balls separately in the properties panel, as shown in Figure 7;



Figure 7 laying out the main scene

7. Back to layer initialize, add the following action to frame 1th:

Xangle = "5";
Yangle = "5";

Add the following action on frame 2nd:

Set ("Cos-42", 0.743144825451055);

Set ("cos-41", 0.754709580197564);

Set ("Cos-40", 0.766044443094884);

Set ("cos-39", 0.777145961433975);

Set ("cos-38", 0.788010753584805);

Set ("cos-37", 0.798635510026434);

Set ("Cos-36", 0.809016994355128);

Set ("Cos-35", 0.819152044270192);

Set ("Cos-34", 0.829037572537239);

Set ("Cos-33", 0.838670567928596);

Set ("Cos-32", 0.848048096140553);

Set ("Cos-31", 0.857167300687171);

Set ("Cos-30", 0.866025403770406);

Set ("cos-29", 0.874619707126247);

Set ("Cos-28", 0.882947592846643);

Set ("Cos-27", 0.891006524176917);

Set ("Cos-26", 0.898794046288515);

Set ("cos-25", 0.906307787026791);

Set ("Cos-24", 0.913545457633494);

Set ("Cos-23", 0.920504853444072);

Set ("Cos-22", 0.927183854559112);

Set ("Cos-21", 0.933580426490206);

Set ("Cos-20", 0.939692620779555);

Set ("Cos-19", 0.945518575593583);

Set ("Cos-18", 0.951056516290005);

Set ("Cos-17", 0.956304755958442);

Set ("Cos-16", 0.961261695934258);

Set ("Cos-15", 0.965925826285507);

Set ("Cos-14", 0.970295726272901);

Set ("Cos-13", 0.974370064782571);

Set ("Cos-12", 0.97814760073155);

Set ("Cos-11", 0.981627183445777);

Set ("Cos-10", 0.984807753010664);

Set ("Cos-9", 0.987688340593903);

Set ("Cos-8", 0.990268068740611);

Set ("Cos-7", 0.992546151640607);

Set ("Cos-6", 0.994521895367765);

Set ("Cos-5", 0.996194698091423);

Set ("Cos-4", 0.997564050259649);

Set ("Cos-3", 0.998629534754517);

Set ("Cos-2", 0.999390827019125);

Set ("Cos-1", 0.999847695156465);

Set ("Cos0", 1);

Set ("Cos1", 0.999847695156465);

Set ("Cos2", 0.999390827019125);

Set ("Cos3", 0.998629534754517);

Set ("Cos4", 0.997564050259649);

Set ("Cos5", 0.996194698091423);

Set ("Cos6", 0.994521895367765);

Set ("Cos7", 0.992546151640607);

Set ("Cos8", 0.990268068740611);

Set ("Cos9", 0.987688340593903);

Set ("Cos10", 0.984807753010664);

Set ("Cos11", 0.981627183445777);

Set ("Cos12", 0.97814760073155);

Set ("Cos13", 0.974370064782571);

Set ("Cos14", 0.970295726272901);

Set ("Cos15", 0.965925826285507);

Set ("Cos16", 0.961261695934258);

Set ("Cos17", 0.956304755958442);

Set ("Cos18", 0.951056516290005);

Set ("Cos19", 0.945518575593583);

Set ("Cos20", 0.939692620779555);

Set ("Cos21", 0.933580426490206);

Set ("Cos22", 0.927183854559112);

Set ("Cos23", 0.920504853444072);

Set ("Cos24", 0.913545457633494);

Set ("Cos25", 0.906307787026791);

Set ("Cos26", 0.898794046288515);

Set ("Cos27", 0.891006524176917);

Set ("Cos28", 0.882947592846643);

Set ("Cos29", 0.874619707126247);

Set ("Cos30", 0.866025403770406);

Set ("Cos31", 0.857167300687171);

Set ("Cos32", 0.848048096140553);

Set ("Cos33", 0.838670567928596);

Set ("Cos34", 0.829037572537239);

Set ("Cos35", 0.819152044270192);

Set ("Cos36", 0.809016994355128);

Set ("Cos37", 0.798635510026434);

Set ("Cos38", 0.788010753584805);

Set ("Cos39", 0.777145961433975);

Set ("Cos40", 0.766044443094884);

Set ("Cos41", 0.754709580197564);

Add the following action on frame 3rd:

Set ("Sin-42",-0.669130606388214);

Set ("sin-41",-0.65605902901961);

Set ("Sin-40",-0.642787609715359);

Set ("Sin-39",-0.629320391078343);

Set ("sin-38",-0.615661475353822);

Set ("sin-37",-0.60181502317984);

Set ("Sin-36",-0.587785252319867);

Set ("Sin-35",-0.573576436378012);

Set ("Sin-34",-0.559192903497261);

Set ("Sin-33",-0.544639035041061);

Set ("Sin-32",-0.529919264258734);

Set ("Sin-31",-0.515038074935051);

Set ("Sin-30",-0.500000000024441);

Set ("Sin-29",-0.4848096202702);

Set ("Sin-28",-0.469471562809151);

Set ("Sin-27",-0.453990499762182);

Set ("Sin-26",-0.438371146811064);

Set ("Sin-25",-0.422618261762019);

Set ("Sin-24",-0.406736643096434);

Set ("Sin-23",-0.390731128509199);

Set ("Sin-22",-0.37460659343508);

Set ("Sin-21",-0.35836794956371);

Set ("Sin-20",-0.34202014334332);

Set ("Sin-19",-0.32556815447403);

Set ("Sin-18",-0.309016994391028);

Set ("Sin-17",-0.292371704738003);

Set ("Sin-16",-0.275637355831441);

Set ("Sin-15",-0.258819045116126);

Set ("Sin-14",-0.241921895612425);

Set ("Sin-13",-0.224951054355759);

Set ("Sin-12",-0.207911690828781);

Set ("Sin-11",-0.190808995386685);

Set ("Sin-10",-0.173648177676178);

Set ("Sin-9",-0.156434465048579);

Set ("Sin-8",-0.139173100967505);

Set ("Sin-7",-0.121869343411672);

Set ("Sin-6",-0.104528463273256);

Set ("Sin-5",-0.0871557427523399);

Set ("Sin-4",-0.0697564737478767);

Set ("Sin-3",-0.0523359562457615);

Set ("Sin-2",-0.0348994967043783);

Set ("Sin-1",-0.0174524064382223);

Set ("Sin0", 0);

Set ("Sin1", 0.0174524064382223);

Set ("Sin2", 0.0348994967043783);

Set ("Sin3", 0.0523359562457615);

Set ("Sin4", 0.0697564737478767);

Set ("Sin5", 0.0871557427523399);

Set ("Sin6", 0.104528463273256);

Set ("Sin7", 0.121869343411672);

Set ("Sin8", 0.139173100967505);

Set ("Sin9", 0.156434465048579);

Set ("Sin10", 0.173648177676178);

Set ("Sin11", 0.190808995386685);

Set ("Sin12", 0.207911690828781);

Set ("Sin13", 0.224951054355759);

Set ("Sin14", 0.241921895612425);

Set ("Sin15", 0.258819045116126);

Set ("Sin16", 0.275637355831441);

Set ("Sin17", 0.292371704738003);

Set ("Sin18", 0.309016994391028);

Set ("Sin19", 0.32556815447403);

Set ("Sin20", 0.34202014334332);

Set ("Sin21", 0.35836794956371);

Set ("Sin22", 0.37460659343508);

Set ("Sin23", 0.390731128509199);

Set ("Sin24", 0.406736643096434);

Set ("Sin25", 0.422618261762019);

Set ("Sin26", 0.438371146811064);

Set ("Sin27", 0.453990499762182);

Set ("Sin28", 0.469471562809151);

Set ("Sin29", 0.4848096202702);

Set ("Sin30", 0.500000000024441);

Set ("Sin31", 0.515038074935051);

Set ("Sin32", 0.529919264258734);

Set ("Sin33", 0.544639035041061);

Set ("Sin34", 0.559192903497261);

Set ("Sin35", 0.573576436378012);

Set ("Sin36", 0.587785252319867);

Set ("Sin37", 0.60181502317984);

Set ("Sin38", 0.615661475353822);

Set ("Sin39", 0.629320391078343);

Set ("Sin40", 0.642787609715359);

Set ("Sin41", 0.65605902901961);

The last Timeline window is shown in Figure 8:


Figure 8 Main scene Timeline window



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.