Test1FL
Test1 for wonderfl
// Test1 for wonderfl
package {
import flash.display.Sprite;
import flash.events.Event;
[SWF(width="465", height="465",
backgroundColor="0x666666", frameRate="30")]
public class Test1FL extends Sprite {
public function Test1FL() {
main = this;
initialize();
addEventListener(Event.ENTER_FRAME, update);
}
}
}
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.filters.*;
import flash.geom.*;
import flash.utils.*;
const SCREEN_WIDTH:int = 465;
const SCREEN_HEIGHT:int = 465;
const color1:Array =
[0x996600, 0x009999, 0x9900FF, 0x009900, 0x0000FF,
0xCC3333, 0x99CC00, 0x330033, 0x00CC99, 0x990000, 0x666666];
const color2:Array =
[0xFFFF33, 0x99CCFF, 0xCC99FF, 0xCCFF33, 0x33CCFF,
0xFF99CC, 0xFFFF99, 0x993399, 0x33FFCC, 0xCC3300, 0xCCCCCC];
var main:Sprite;
var ballAry:Array;
function initialize():void {
var tmpSpr:Sprite;
ballAry = new Array();
for (var i:int = 0; i < 64; i++) {
tmpSpr = aquaCircle(20, int(Math.random() * 10), null);
tmpSpr.x = Math.random() * 465;
tmpSpr.y = Math.random() * 465;
main.addChild(tmpSpr);
ballAry.push(tmpSpr);
}
}
function update(e:Event):void {
for (var i:int = 0; i < ballAry.length; i++) {
ballAry[i].x += Math.random() * 8.0 - 4.0;
if (ballAry[i].x < 0)
ballAry[i].x = 0;
if (ballAry[i].x > SCREEN_WIDTH)
ballAry[i].x = SCREEN_WIDTH;
ballAry[i].y += Math.random() * 8.0 - 4.0;
if (ballAry[i].y < 0)
ballAry[i].y = 0;
if (ballAry[i].y > SCREEN_HEIGHT)
ballAry[i].y = SCREEN_HEIGHT;
}
}
function aquaCircle(radius:Number, type:int,
sprite:Sprite = null):Sprite {
if (!sprite) {
sprite = new Sprite()
}
var matrix:Matrix = new Matrix();
matrix.createGradientBox(radius * 2, radius * 2,
Math.PI / 2, -radius, -radius);
var graphics:Graphics = sprite.graphics;
graphics.lineStyle(2, color1[type]);
graphics.beginGradientFill(GradientType.LINEAR,
[color1[type], color2[type]],
[1.0, 1.0], [0x00, 0xFF], matrix);
graphics.drawCircle(0, 0, radius);
graphics.endFill();
graphics.lineStyle(undefined);
graphics.beginFill(0xFFFFFF, 0.5);
graphics.drawEllipse(-radius / 2, -radius * 0.95,
radius, radius * 0.6);
graphics.endFill();
return sprite;
}