Advanced vibration effect using the AS3

Date: 2.7.2009, 14:51    Total views: 12494

Using this thoroughly explained, detailed action script 3 flash lesson, you will see how to create advanced vibration effect. You can apply this effect on any object, image. You can also use it for some flash banner or animation. Using this lesson, you will also learn how to convert any object into a movie clip symbol, how to create instance name and much much more! Let's go!

Example:



Step 1

Create a new flash document. Press Ctrl+J key on the keyboard (Document Properties) and set the dimensions of your document as whatever you like. Select any color as background color. Set your Flash movie's frame rate to 30 and click ok.



Step 2


Draw any object or import any image into a flash stage which you like to use for this lesson.

Step 3

While the image or object is still selected, hit F8 key (Convert to Symbol) to convert it into a Movie Clip Symbol.

Step 4

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 image_mc. See the picture below!



Step 5

Select now the first frame of layer 1 and go to the AS panel (F9). After that, enter this code inside the actions panel:

var posx:Number = image_mc.x; 
var posy:Number = image_mc.y; 
image_mc.addEventListener(Event.ENTER_FRAME, shakeIt); 
function shakeIt(event:Event):void { 
image_mc.x = posx+(Math.floor(Math.random()*8)); 
image_mc.y = posy+(Math.floor(Math.random()*8)); 
image_mc.rotation = Math.random()*12; 


We're done!

Test your movie and enjoy!

Download source file (.fla)

  Digg it! Add this tutorial to del.icio.us! Furl it! Add this tutorial to reddit! Spurl it! Add this tutorial to technorati!
Share
ShareSidebar