In this tutorial we are going to develop a movie clip with a very simple dynamic motion blur. This means that we can set the number of instances that will produce the blur effect instead of manually doing the same job. Of course this approach has got the advantage that we can easily change the parameters with minimal effort.
IntroductionTo dynamically create the motion blur, we need to duplicate the original movie clip. However, every new instance should have a different value of alpha and displacement.
Engine betaIn this example we need two movie clips: one for the object with motion blur and another for the cursor, which will be in fact the responsible of creating the effect. Once we created the object, we need to place one instance in the root –called heart for example. And we need to place one instance of the another movie clip too, instanced in our code as katie.
The idea is that katie and heart –and all its duplications- would follow the mouse. As we said, the movie clip acting like cursor is responsible of creating new instances of the other movie.
And since the copies are dynamically created, we need to remove them.
You have the change to use the option with() that provides Flash, but we preferred a more explicit version.
As it is easy to see, the most important variable is HEARTS, that indicates the number of instances to be created.
onClipEvent (load)
{
HEARTS=10;
Mouse.hide();
for (i=0;i<HEARTS;i++)
{
_root.heart.duplicateMovieClip("heart"+i,i);
eval("_root.heart"+i)._alpha=(i+1)/HEARTS*25;
}
}
onClipEvent (unload)
{
for (i=0;i<HEARTS;i++)
eval("_root.heart"+i).removeMovieClip();
}
onClipEvent (enterFrame)
{
_x=_root._xmouse;
_y=_root._ymouse;
_root.heart._x+=_root._xmouse-_root.heart._x;
_root.heart._y+=_root._ymouse-_root.heart._y;
for (i=0;i<HEARTS;i++)
{
heart=eval("_root.heart"+i);
mult=(i+1)/(HEARTS+HEARTS);
heart._x+=(_root._xmouse-heart._x)*mult;
heart._y+=(_root._ymouse-heart._y)*mult;
}
} |
ConclusionIn this example we created a simple dynamic motion blur that can be easily changed. It presents notorious advantages over the static version, and it can be used even in examples like text blur, shown in previous tutorials.