Toxiclab.org

Vibration animation by action script

26.4.2008, 19:26
Submited in: Flash | Total Views: 42350

In this easy lesson, I will show you how to apply vibration effect on any object using the action script code. You will also learn how to create instance name, how to convert any symbol into a Movie Clip Symbol and much more.



Step 1

Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the width of your document to 350 pixels and the height to 300 pixels. Select white color as background color.Set your Flash movie's frame rate to 28 and click ok. See the picture below.





Step 2


Draw or import any picture, object which you like to use for this example. You can also if you like, save my picture below.



Step 3

After that, choose File > Import > Import to Stage (Ctrl+R) and import that objet into a flash.

Step 4

While the object is still selected, press F8 key (Convert to Symbol) to convert this object into a Movie Clip Symol.



Step 5

While the new made Movie Clip is still selected, go to the Properties Panel below the stage. On the left side, You will find the Instance name input field there. Call this Movie Clip object. See the picture below.



Step 6

Take the Selection Tool (V) and click once on the object to select it. Afte that, go to the action script panel (F9) and enter the following action script code inside the panel:

onClipEvent (load) {
height = 350;
width = 300;
this._x = Math.round(Math.random()*width);
this._y = Math.round(Math.random()*height);
var temp = this._alpha=Math.random()*80;
this._xscale = this._yscale=temp;
cx = this._x;
cy = this._y;
}

onClipEvent (enterFrame) {
this._x = cx+(1+Math.random()*7);
this._y = cy+(Math.random()*7);
}

Step 7

After that, click on the first frame of layer object and go again to the action script panel. Then, enter this code inside the actions panel:

for (var i = 0; i<25; i++) {
object.duplicateMovieClip(i, i);
}

Test your Movie (Ctrl+Enter).

We're done!

Download example

Are you a website owner?
Click here to register and submit your tutorials!

Browse by category


Most popular tutorials


Resources Worth visiting


Friends