forked from: flash on 2010-9-15
▼インポート宣言
▼クラス宣言
♥0 |
Line 70 |
Modified 2011-01-04 12:32:42 |
MIT License
archived:2017-03-20 13:22:29
ActionScript3 source code
/**
* Copyright Aksor.Al ( http://wonderfl.net/user/Aksor.Al )
* MIT License ( http://www.opensource.org/licenses/mit-license.php )
* Downloaded from: http://wonderfl.net/c/gbk3
*/
// forked from tra's flash on 2010-9-15
package{
//▼インポート宣言
import flash.display.Sprite;
import flash.display.MovieClip;
import flash.display.Stage;
import flash.display.StageQuality;
import flash.media.Sound;
import flash.media.SoundLoaderContext;
import flash.media.SoundChannel;
import flash.media.SoundMixer;
import flash.net.URLRequest;
import flash.events.Event;
import flash.utils.ByteArray;
import flash.geom.ColorTransform;
import flash.filters.GlowFilter;
import flash.filters.BitmapFilterQuality;
[SWF(backgroundColor="#000000",frameRate="60",width="500",height="500")]
//▼クラス宣言
public class HachioGizaGiza extends MovieClip{
//▼メンバ変数
private var soundObj:Sound;
private var soundLoaderContext:SoundLoaderContext;
private var soundChannel:SoundChannel;
private var FFTswitch:Boolean=false;
private var graphContanier:Sprite=new Sprite();
private var hachio:Sprite=new Sprite();
private var count:Number=0;
//▼コンストラクタ
public function HachioGizaGiza(){
stage.quality = StageQuality.MEDIUM;
Wonderfl.capture_delay(15);
this.soundPlay("http://scfire-dtc-aa03.stream.aol.com:80/stream/1035");
//TsabeatRobotWarrior
addChild(this.graphContanier=new Sprite());
//trace(stage.stageHeight);
hachio.filters=[new GlowFilter(0x000000,0.5,2,2,2,BitmapFilterQuality.HIGH,false,false)];
graphContanier.addChild(hachio);
this.addEventListener(Event.ENTER_FRAME,effectEnterFrame);
}
//▼音楽再生
private function soundPlay(filePath:String):void{
this.soundObj=new Sound();
this.soundLoaderContext = new SoundLoaderContext(1000,true);
this.soundObj.addEventListener(Event.COMPLETE,soundComplete);
this.soundObj.load(new URLRequest(filePath),this.soundLoaderContext);
}
private function soundComplete(e:Event):void{
this.soundObj.play(0,50);
}
private function effectEnterFrame(e:Event):void{
this.hachio.graphics.clear();
var bytes:ByteArray = new ByteArray();FFTswitch
SoundMixer.computeSpectrum(bytes, this.FFTswitch, 0);
hachio.graphics.lineStyle(1,0xff0000,1);
this.hachio.graphics.moveTo(0,stage.stageHeight/2);
bytes.position=0;
for (var i:Number = 0;i < 255;i++) {
if(i % 1==0){
//ビートの取得
var rf:Number = bytes.readFloat();
var vol:Number = rf;
//ランダムに生成されるビートの値を加工
var scale:Number = rf * -100;//投げた引数の大きいほうを取得
if(i==1){
}
this.hachio.graphics.lineTo((stage.stageWidth+3) / 256 * i,scale+stage.stageHeight/2);
if(vol >0.6){
changed();
}
}
}
}
private function changed():void {
var hex:uint = [0xFF4C52,0xE8E04A,0x2AC8FF,0x0022FF4C,0xC190E8][count++ % 5];
this.hachio.transform.colorTransform = new ColorTransform(0, 0, 0, 1,hex >> 16 & 0xff,hex >> 8 & 0xff,hex & 0xff,1);
}
}
}