آموزش فلش و اکشن اسکریپت

معرفی منابع اکشن اسکریپت و فلش و آموزش کار با فلش

آموزش فلش و اکشن اسکریپت

معرفی منابع اکشن اسکریپت و فلش و آموزش کار با فلش

افکت نقطه های تصادفی

Random dots effect

  





دانلود سورس کد : افکت نقطه های تصادفی


برای دیدن آموزش ، ادامه مطلب را ببینید :

Random dots effect

22.5.2009, 11:30    Total views: 19472

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;
 
 this.speed = Math.random()*6+3;
 this.targx = Math.random()*width;
 this.targy = Math.random()*height;
 dist = _root.getdistance(this.x, this.y, this.targx, this.targy);
 norm = this.speed/dist;
 this.diffx = (this.targx-this.x)*norm;
 this.diffy = (this.targy-this.y)*norm;
};

MovieClip.prototype.move = function() {
 if (_root.getdistance(this.x, this.y, this.targx, this.targy)>this.speed) {
  this.x += this.diffx;
  this.y += this.diffy;
 } else {
  this.x = this.targx;
  this.y = this.targy;
  if (!this.t) {
   this.t = getTimer();
  }

  if (getTimer()-this.t>1000) {
   this.reset();
   this.t = 0;
  }
 }
 this._x = this.x;
 this._y = this.y;
};

Step 11

Select now dot and duplicate it (Ctrl+D) as many times as you want

We're done now!

Test your Movie (Ctrl+Enter) and enjoy!

نظرات 0 + ارسال نظر
برای نمایش آواتار خود در این وبلاگ در سایت Gravatar.com ثبت نام کنید. (راهنما)
ایمیل شما بعد از ثبت نمایش داده نخواهد شد