In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

forked from: flash on 2009-4-18

Get Adobe Flash player
by grze 12 Aug 2009
// forked from nukerito's flash on 2009-4-18
package {
    import flash.display.Sprite;
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.geom.Matrix;
    import flash.display.GradientType;
    
    public class FlashTest extends Sprite {
        public function FlashTest() {
            // write as3 code here..
            init();
        }
        
        public function init():void
        {
        
        
        
        
        // variables
var clouds:uint = 15; //count of clouds
var minY:uint = 20; // minimum y position of the cloud
var maxY:uint = 50; // maximum y position of the cloud
var minSpeed:Number = 0.5; // minimum speed
var maxSpeed:Number = 2; // maximum speed
var minScale:Number = .3; // minimum scale
var maxScale:Number = 2; // maximum scale

// place cloud instances on stage
for (var i:uint = 0; i < clouds; i++) {
var scaleFactor = randRange(minScale, maxScale);
var c:MovieClip = drawCloud();
c.x = randRange(0, stage.stageWidth);
c.y = randRange(minY, maxY);
c.speed = randRange(minSpeed, maxSpeed);
c.scaleX = scaleFactor;
c.scaleY = scaleFactor;
c.addEventListener(Event.ENTER_FRAME, update);
addChild(c);
}
// update cloud position
function update(e:Event):void {
var cloud:MovieClip = MovieClip(e.target);
cloud.x -= cloud.speed;
if((cloud.x + cloud.width) < 0) {
cloud.x = stage.stageWidth;
}
}
// draw cloud
function drawCloud():MovieClip	{
var matrix:Matrix = new Matrix();
matrix.createGradientBox(100, 100, 45);
var cloud:MovieClip = new MovieClip();
cloud.graphics.beginGradientFill(GradientType.LINEAR, [0x11CCFF, 0x4488FF], [1, 1], [0, 255], matrix); 
cloud.graphics.drawEllipse(0, 0, 200, 100);
return cloud;
}
// generate random number
function randRange(min:Number, max:Number):Number	{
var randomNumber:Number = Math.floor(Math.random() * (max - min + 1)) + min;
return randomNumber;
}
        
        
        
            
        }
    }
}