Monday, October 25, 2010

Flash CS4 produced results falling dream spark



The case is an instance in the expansion based on the calculated to produce the mouse to follow an object with certain laws spark effects.

Thinking

Import the background material, then produce spark effects.

Create a document class, resulting in the mouse to follow the polygonal star effects; create a component class to extend the class size of sparks generated random effect.

Effects produced Spark Part 1

(1) create a new size of 500 脳 300 pixel, 30fps frame rate for the blank document. Press Ctrl + R key combination into the CD-ROM in the "Chapter08 / material / Lake night. Jpg" file, then set the coordinates (0,0), then using the previous method in the "Properties" panel add a Main Document class.

(2) press Ctrl + F8 key combination to create a new movie clip (named Star_mc), into the movie clip's editing area, then hold down Shift + Alt key combination while using the "ellipse tool" in the center of the movie clip draw a circle.

Tips & Hints:

Graphic fill-color type as "radial", the first a color color (R: 255, G: 0, B: 0), the first two color-color (R: 153, G: 0, B: 0 ), the first three color color (R: 153, G: 0, B: 0), Alpha to 0%.

(3) Create a new star layer, and then click the "toolbox" in the "Multilateral star Tools" button, and in the "Properties" panel, set up the parameters of the tool, then hold down Shift + Alt key combination while the center of the movie clip draw a star.

(4) use the "select tool" to readjust the star of the vertex position, as shown in Figure 8-4.

(5) Select the adjustment of a good polygonal star-shaped, and in situ out a copy, press Ctrl + Alt + S key combination to open the "zoom and rotate" dialog box, set the zoom to 40% and then set its color to white.

(6) to return to the "Scene 1", press Ctrl + F8 key combination to create a new movie clip (named Magic_mc), then set the fill type to "radial", the first a color color (R: 255, G: 255 , B: 255), No. 2 color color (R: 255, G: 255, B: 204), the first three color color (R: 255, G: 204, B: 0), 4 a color color (R: 255, G: 102, B: 0), the first five color color (R: 153, G: 0, B: 0), Alpha to 0%, then hold down the Alt key while using the "rectangle tool" to the center of the movie clip as a starting point to draw a rectangle as shown in Figure 8-6.

(7) The use of "arbitrary deformation tool" selection rectangle, and then press Ctrl + T key combination to turn "distortion" panel, set the rotation to 45 掳, and then click the "reproduction constituencies and deformation" button, copy the three copies of graphics.

(8) replicate 5 graphics, then adjust the color as shown in Figure 8-8, and then copy the graphic into the movie clip, and its name 01,02,03,04 and 05, respectively .

(9) 01,02,03,04 and 05 video clips were placed at Magic_mc layer 5 key frames, and then were to add different "light" filter, and then create a new AS layer, and finally "Actions - Frame" panel, type stop (): program.

Part 2 Creating element class

(1) using the previous method were Magic_mc and Star_mc movie clip added component class.

(2) Create a new ActionScript file, named Main, and then save it in the instance of the folder, then enter the control code.

/ **

* Class-based program class

* @ Author lbynet

* @ Version 0.1

* /

package (

import flash.display.Sprite;

import flash.display.MovieClip;

import flash.events.Event;

import flash.events.MouseEvent;

import flash.ui.Mouse;

public class Main extends Sprite (

private var star: MovieClip;

public function Main () (

Mouse.hide ();

this.star = new Star_mc ();

addChild (star);

stage.addEventListener (MouseEvent.MOUSE_MOVE, moveHandler);

)

private function moveHandler (e: MouseEvent): void (

this.star.x = stage.mouseX;

this.star.y = stage.mouseY;

var _mc = new Magic_mc ();

_mc.x = stage.mouseX;

_mc.y = stage.mouseY;

addChild (_mc);

_mc.addEventListener (Event.ENTER_FRAME, RemoveDrop);

)

private function RemoveDrop (event: Event) (

var _mc: MovieClip = event.target as MovieClip;

if (_mc.scaleX <= 0) (

_mc.removeEventListener (Event.ENTER_FRAME, RemoveDrop);

removeChild (_mc);

)

/ / Trace (this.numChildren)

)

)

)

Tips & Hints:

The document class basically contains the "stars falling on" Main document class instance of knowledge, in addition to 18 lines of code for the Mouse class hide () methods for hiding the mouse pointer, before using this method must first import the Mouse class (such as 11 lines of code).

The document class defines a private property of Star, the first 19 lines of code is assigned for the property, the value created component class (Star_mc), and added to the display list (such as the first 20 lines of code), while 24 and 25 lines of code is the class of applications for the device to follow the effect of the mouse.

(3) also create a new ActionScript file, and then enter the control code.

/ **

* Components such as the expansion of class

* @ Author lbynet

* @ Version 0.1

* /

package (

import flash.display.MovieClip;

import flash.events.Event;

public class Magic_mc extends MovieClip (

private var dis: Number;

public function Magic_mc () (

init ();

)

private function init () (

var Random = 1 + Math.round (Math.random () * 4);

this.gotoAndStop (Random);

this.scaleX = this.scaleY = Math.random ();

/ / Generate random numbers -5 to 5 random numbers between

dis = Math.round ((Math.random () -. 5) * 10);

this.addEventListener (Event.ENTER_FRAME, enterFrameHandler);

)

private function enterFrameHandler (event: Event) (

this.y + = 5;

this.x + = dis;

this.scaleX -=. 005;

this.scaleY -=. 005;

)

)

)

Tips & Hints:

19 and 20 lines of code is the element type to create a 1 to 5 random numbers between, so that the movie clip an instance of component class (being created) will play the first move and stop at a specified time frame .

Math.random () method between 0 and 1 generated random number, Math.random () * 4 ways to return to the 0 to 4 random numbers between, but Math.round () method is used to rounding up or down to the nearest integer and returns the value, so 1 + Math.round (Math.random () * 4) method to obtain 1 to 5 random integer value between; gotoAndStop () statement to make the first move to play the movie clip and stop at a specified time frame.

By using Math.random () -0.5 -0.5 0.5 method to generate random number between, and then be multiplied by 10 -5 to 5 random numbers between, and then use the Math.round method and obtain integer rounding, so that when the mouse pointer moves from down to up, it will produce the effect of spark falling.

30 lines of code is to join the y-axis coordinate spark a fixed direction of acceleration, and the first 31 lines of code is the spark coordinates in the x-axis direction between a -5 to 5 random acceleration.

(4) Press Ctrl + Enter key combination release program







相关链接:



JMP Fine China Senior DOE effort to BUILD training courses



The fourth PRINCIPLE of the infrastructure



REVIEW Calculators And Converters



How To Clean Up Laptop Notebook Liquid Spill



Picked Business Databases And Tools



[Death Spy: decision time] menu option to translate



Evaluate XML Or CSS Tools



RM to MPEG4



AVI To Zune



"Steal" food reform "Abstract" dishes: Without Thieves lonely farm still in the



Analysis Of Taobao In 2008 To Adjust The Causes And Effects Of B2C Strategy



Further than South Korea, Japan and China Shipbuilding Industry



DB2 basics



Transport Stream Converter



No comments:

Post a Comment