import com.greensock.*;
import com.greensock.plugins.*;
import com.greensock.easing.*;
//*****====================================================*****
var clouds:TimelineMax = null;
var cloudArray:Array = new Array();
cloudArray.push('cloud1');
cloudArray.push('cloud2');
cloudArray.push('cloud3');
cloudArray.push('cloud4');
init();
function init():void {
clouds = new TimelineMax({repeat:-1, yoyo:true, repeatDelay:3});
for(var i:int = 0; i < cloudArray.length; i++) {
var cloud:MovieClip = this[cloudArray[i]] as MovieClip;
var dur:int = rndm(100, 120);
var del:int = (i == 0) ? 0 : (i* 10 + 10);
cloud.alpha = 0;
TweenMax.to(cloud, 1, {blurFilter:{blurX:75}});
clouds.insert(TweenMax.to(cloud, 10, {x:"100"}));
clouds.insert(TweenMax.to(cloud, 10, {alpha:1, delay:del + 5}));
clouds.insert(TweenMax.to(cloud, dur, {x:1200, delay:del}));
clouds.insert(TweenMax.to(cloud, dur, {scaleX:1.25, delay:del}));
clouds.insert(TweenMax.to(cloud, dur, {scaleY:1.5, delay:del}));
// This should fade out the cloud near the end
clouds.insert(TweenMax.to(cloud, 20, {alpha:0, delay:del + dur - 20}));
}
}
/**
* Generate a random number
* @return Random Number
* @error throws Error if low or high is not provided
*/
function rndm(low:Number=NaN, high:Number=NaN):Number
{
var low:Number = low;
var high:Number = high;
if(isNaN(low)) {
throw new Error("low must be defined");
}
if(isNaN(high)) {
throw new Error("high must be defined");
}
return Math.round(Math.random() * (high - low)) + low;
}
|