EKG monitor animation using the AS3

Date: 3.7.2009, 13:59    Total views: 10586

This, step by step, detailed action script lesson, will show you how to create EKG monitor animation using the AS3. You can use this animation for some flash banner or flash header. Let's start!










Example:



Step 1

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



Step 2


Call the current layer EKG monitor. Double-click on its default name (Layer 1) to change it. Press Enter once you have typed in the new name!

Step 3

Select the first frame of layer EKG monitor and go to the Action Script panel (F9). After that, enter this code inside the actions panel:

var oldX:Number = 2; 
var oldY:Number = 380; 
var randomX:Number; 
var randomY:Number; 

this.graphics.lineStyle(2,0xb1e5f3); 

this.graphics.moveTo(oldX,oldY); 
this.addEventListener(Event.ENTER_FRAME, drawRandom);


function drawRandom(event:Event):void { 
randomX = oldX + Math.random() * 2; 
randomY = 60 + Math.tan(oldY + Math.random() * 3); 
this.graphics.lineTo(randomX,randomY); 
oldX = randomX; 
oldY = randomY; 


We're done now!

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