// Случайное число
function randomNumb(min, max) {
var number:Number = Math.random()*(max-min)+min;
return number;
}
// Движение листьев
function mover() {
firstTime = 1;
this._y += this.speed;
this.xCounter += this.step;
if (this.xCounter>20) {
this.step = -1;
this.xSpeed *= -1;
}
if (this.xCounter<-20) {
this.step = 1;
this.xSpeed *= -1;
}
if (this.xCounter<10 && this.xCounter>-10) {
this._x += this.xSpeed;
}
if ((this.xCounter<=-10 && this.xCounter>=-15) || (this.xCounter>=10 && this.xCounter<=15)) {
this._x += (this.xSpeed/2);
}
if (this.xCounter>15 || this.xCounter<-15) {
this._x += (this.xSpeed/3);
}
if (this._y>(Stage.height+this._height)) {
reStart(this);
}
}
// Установка начальных параметров скорости, размера, положения.
function reStart(clip, rotat) {
clip._x = randomNumb(0, Stage.width);
clip._y = -clip._height;
clip.speed = randomNumb(1, 3);
clip.xSpeed = clip.speed*2*clip.step;
clip._xscale = clip._yscale=randomNumb(30, 50);
if (rotat) {
clip._rotation = randomNumb(-180, 180);
}
if (firstTime == underfined) {
clip._y = randomNumb(0, Stage.height);
}
}
// Определяем первоначальное движение
function step() {
var myStep = Math.random();
if (myStep>0.5) {
myStep = 1;
} else {
myStep = -1;
}
return myStep;
}
// Первоначальная загрузка картинок
function myBg(n) {
var bg:MovieClip = this.createEmptyMovieClip("bg", 0);
var dep:Number = 0;
for (i=0; i
var list1:MovieClip = bg.attachMovie("list1", "list1"+i, dep++);
var list2:MovieClip = bg.attachMovie("list2", "list2"+i, dep++);
var list3:MovieClip = bg.attachMovie("list3", "list3"+i, dep++);
list1.step = step();
list2.step = step();
list3.step = step();
reStart(list1, true);// лист повернется
reStart(list2, true);
reStart(list3, false);// не повернется
list1.xCounter = randomNumb(-20, 20);
list2.xCounter = randomNumb(-20, 20);
list3.xCounter = randomNumb(-20, 20);
list1.onEnterFrame = mover;
list2.onEnterFrame = mover;
list3.onEnterFrame = mover;
}
}
// Аттачим листья
myBg(4);