In this thoroughly explained, detailed flash lesson, I will
show you how to create fantastic random dots effect in flash using the
action script code. You can use this effect for some banner, or some
flash animation. Using this lesson, you will also learn how to import
any image into a flash stage, how to create blue dots using the Color
Panel (Shift+F9) and much much more!
Example:
Step 1
First, save the image below that we will use for this lesson as background.
Step 2
Create
a new flash document. Press Ctrl+J key on the keyboard (Document
Properties) and set the width of your document to 450 pixels and the
height to 409 pixels. Select white as background color. Set your Flash
movie's frame rate to 55 and click ok.
Step 3
Call
the current layer background. Double-click on its default name (Layer
1) to change it. Press Enter once you have typed in the new name!
Step 4
Choose
now File > Import > Import to stage (Ctrl+R) and import the image
that you just saved in step 1 into a flash stage. While the image is
still selected, go to the Align Panel (Ctrl+K) and do the following:
1. Make sure that the Align/Distribute to Stage button is turned on, 2. Click on the Align horizontal center button and 3. Click the Align vertical center button.
Step 5
Create a new layer above the layer background and name it dots.
Step 6
Select
dots layer, and take the Oval Tool (O). In the Colors portion of the
Tool panel, block the Stroke color by clicking on the little pencil icon
and then on the small square with the red diagonal line. For Fill color
choose any color and draw a circle shape about 2525 px like it is shown
on the picture below!
Step 7
After that, go to the Color Panel (Window > Color), select Radial for Fill type and make the adjustments as follows:
Step 8
While the dot is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.
Step 9
Select
now the Selection Tool (V) and click once on the dot to select it.
After that, go to the Action Script Panel (F9) and enter this code
inside the actions panel:
onClipEvent(enterFrame){ move(); }
Step 10
Select
again the Selection Tool (V) and click once on the first frame of layer
dots. After that, go again to the AS panel (F9) and enter this code
inside the actions panel:
function getdistance(x, y, x1, y1) { var run, rise; run = x1-x; rise = y1-y; return (_root.hyp(run, rise)); } function hyp(a, b) { return (Math.sqrt(a*a+b*b)); } MovieClip.prototype.reset = function() {
width = 450; height = 409;
var dist, norm; this.x = this._x; this.y = this._y;