Friday, 9 January 2009

effect by using mouse click



*move the mouse onto the screen ^^

This is a very simple but beautiful effect. I tried it for my typography assignment.

1/ First, open flash file, then set the high frame rate so the motion will be smooth.
2/ Create 2 layers

-At the first frame of layer 1, insert the element that you are going to let it flying when moving mouse. Remember to convert the element to movie clip and give it an instance name. In this case, i named it "star". You can see this name in the script.












-At the first frame of the second layer, press F9, then copy this code below:

import mx.transitions.Tween;
import mx.transitions.easing.*;
star._visible = false;
var i:Number = 1;
var total:Number = 500;
onMouseMove = function()
{var fm = tim.duplicateMovieClip("fm" + i, total - i );
scale = random(60) + 41;
position_x = _xmouse + random(120) - 60;
position_y = _ymouse + random(60) - 30;
new Tween(fm, "_xscale", Strong.easeOut, 10, scale, 2, true);
new Tween(fm, "_yscale", Strong.easeOut, 10, scale, 2, true);
new Tween(fm, "_alpha", Strong.easeOut, 20, scale, 2, true);
new Tween(fm, "_x", Strong.easeOut, _xmouse, position_x, 2, true);
fm_tween = new Tween(fm, "_y", Strong.easeIn, position_y, 400, 2, true);
fm_tween.onMotionFinished = function()
{removeMovieClip(fm);}
if(i >= total){i = 1;}i++;}

*source: "www.flashmymind.com"

0 comments: