Known For Quality

Blur circular animation using the AS

Blur circular animation using the AS



Step 1

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



Step 2

Select the Oval Shape (O) and draw a circle about 35x35 px. See the picture below!



Step 3

While the circle is still selected, press 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 circle. See the picture below!




Step 5

Select now Filters tab from the left side. Click after that on the plus icon and select the Blur filter. Make the adjustments as follows:



Step 6

Go now to the Flash Library (Ctrl+L), choose right click on circle_mc and select Linkage.



Step 7

In the Linkage Properties window, select Export for ActionScript and for Class type Circle. See the picture below!



click now ok.

Don’t worry about the ActionScript Class Warning. Just click ok!

Step 8

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


var angle:Number = 0;
var speed:Number = 0.5;

var radius:Number = 80;

var centerX:Number = stage.stageWidth / 2;
var centerY:Number = stage.stageHeight / 2;

circle.addEventListener (Event.ENTER_FRAME, moveCircle);

var timer:Timer = new Timer(30,800000);
timer.addEventListener (TimerEvent.TIMER, createTrailCircle);
timer.start ();

function moveCircle (e:Event):void {
var xpos:Number = centerX + Math.cos(angle) * radius;
var ypos:Number = centerY + Math.sin(angle) * radius;

circle.x = xpos;
circle.y = ypos;

angle += speed;
}

function createTrailCircle (e:Event):void {

var trailCircle:Circle=new Circle();

trailCircle.x = circle.x;
trailCircle.y = circle.y;

trailCircle.addEventListener (Event.ENTER_FRAME,animatetrailCircle);

addChildAt (trailCircle,0);
}

function animatetrailCircle (e:Event):void {

e.target.alpha -= 0.04;
e.target.scaleY -= 0.04;
e.target.scaleX -= 0.04;

if (e.target.alpha <>
e.target.removeEventListener (Event.ENTER_FRAME,animatetrailCircle);
removeChild ((MovieClip)(e.target));
}
}

We're done now!

Test your Movie (Ctrl+Enter) and enjoy!

Click here to see the best Flash and Web Development company.

0 comments:

Post a Comment