flash on 2009-11-26
♥0 |
Line 49 |
Modified 2009-11-26 03:40:22 |
MIT License
archived:2017-03-20 01:08:23
ActionScript3 source code
/**
* Copyright hacker_929p08ld ( http://wonderfl.net/user/hacker_929p08ld )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/v66G
*/
package{
import flash.display.*;
import flash.events.*;
import flash.geom.*;
import flash.utils.*;
import flash.filters.*;
/*
一つ前の投稿と同じく、
「miscellaneous」さん
http://yamasv.blog92.fc2.com/blog-entry-157.html
のコードをお借りしています。
*/
public class f22 extends Sprite{
private var balls:Array = [];
private var timer:Timer = null;
private var tick:Number = 0;
private var rad:Number = 0;
private var colors:Array = [0xFF0000, 0xFFFF00, 0xFFFFFF];
private var alphas:Array = [0, 0.5, 1];
private var ratios:Array = [0, 192, 255];
private var gradientGlowFilter:GradientGlowFilter = new GradientGlowFilter(0, 0, colors, alphas, ratios, 32, 32, 3, 3, "outer", false);
private var ball:Ball = new Ball(0xffffff, 30);
public function f22(){
ball.alpha = 0.6;
ball.filters = [gradientGlowFilter];
addChild(ball);
timer = new Timer(50);
timer.addEventListener(TimerEvent.TIMER, cal);
timer.start();
}
private function cal(e:Event) :void{
var x:Number = Math.PI*2*tick - Math.PI;
var fx:Number = 0;
for(var i:Number = 0 ; i < 11 ; i++){
fx += Math.pow(2, -i)*Math.sin(Math.pow(2,i)*x);
}
fx = (fx+1.5)/3;
trace(fx);
rad += fx/10.0;
ball.alpha = fx;
ball.x = Math.cos(rad)*150 + 200;
ball.y = Math.sin(rad)*150 + 200;
tick += 0.01;
if(tick > 1)
tick =0;
}
}
import flash.display.*;
internal class Ball extends Sprite{
public function Ball(color:int, radius:int){
graphics.beginFill(color);
graphics.drawCircle(0,0,radius);
graphics.endFill();
}
}