XML Image Gallery with Falling Pictures (Snow Effect)
| Category | : Flash | Views | : 34390 | ||
| Version | : 8 | Rating | : | ||
| Type | : Text | Source File | : xml-image-gallery-with-falling-pictures.zip | ||
| Result | : See the result | ||||
listener.onLoadInit = function(target)
{
onClipEvent(load)
{
import mx.transitions.Tween;
import mx.transitions.easing.*;
The Tween library is needed for the animation, and the easing for the movement of the animation.
function reset()
{
We created a function for this because we will reuse the code inside when the MC needs new properties.
this._xscale = this._yscale = Math.random() * 6 + 3;
this._alpha = Math.random() * 50 + 50;
this._rotation = Math.random() * 360;
Get random values for the scale, alpha and rotation of the MC.
this._y = Math.random() * 100 - 200;
this._x = Math.random() * Stage.width;
Get a random position for the MC.
yspeed = (Math.random() * 5 + 2);
xspeed = (Math.random() * 4 + 1) * _root.dir;
select = false;
}
Get random speeds, the variable "dir" determinates whether the MC will go left or right.Set the variable "select" to false.
reset();
}
Call the function "reset()"
onClipEvent(enterFrame)
{
if ((!select) && (_root.ready))
{
this._x += xspeed;
this._y += yspeed;
Move the MC if it's not selected and the images are loaded.
}
if(this._y > Stage.height)
{
reset();
}
if(this._x < -50)
{
reset();
}
if(this._x > Stage.width + 50)
{
reset();
}
}
If the MC leaves the screen in any direction we call "reset()" to make the MC fall again.
![]() |
![]() |
![]() |
![]() |
![]() |







