注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

音画试听乐园

我的空间我做主 音乐无极限

 
 
 

日志

 
 
关于我

哥的世界不需要太多人懂。带上耳机.用音樂和麦克风驱赶悲傷,一声长叹何为缘?劳燕分飞两重天。泪眼作别转身去,柔情昨夜已成眠。尘世间的尘缘、以不再为红颜 无痕影音群号87433011 欢迎喜欢唱歌跳舞的你加入

网易考拉推荐

【转载】频谱-004原文件(粒子01-双声道)  

2017-01-03 13:48:02|  分类: FLASH教程 |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

效果浏览:




/***调用代码:(主场景或者Main)***/
import mixViewer.MixViewer;
var mix:MixViewer;
MixViewer.stage = stage;
mix = new MixViewer();
addChild(mix);

/************mixViewer.MixViewer类***********/
package mixViewer
{
import flash.display.Sprite;
import flash.display.Bitmap;
import flash.display.Stage;
import flash.geom.Rectangle;
import flash.geom.Point;
import flash.filters.BlurFilter;
import flash.geom.ColorTransform;
import flash.utils.ByteArray;
import flash.display.Bitmap;
import flash.utils.setTimeout;
import flash.events.MouseEvent;
import flash.events.Event;
import flash.media.SoundMixer;
import flash.display.BitmapData;

public class MixViewer extends Sprite
{
public static var stage:Stage;

private var ins:MixViewer;

private var speedA:Number = 5.5;
private var speedLine:Number = 4.7;
private var ange:Number = 0;
private var visScale:Number = 1;

/***粒子斜度*** xl= ***0、1、0.6、-0.5、1.5***/
private var xl:Number = 1;
private var showW:int = 1024;
private var showH:int = 360;
private var halfShowW:int = 512;
private var scaleA:Number = 1.5;
private var scaleB:Number = 1;
private var _mode:int = 0;
private var mode:uint = 0;
private var frameCount:int = 0;
private var lineScaleValue:Number = 3.53;

private var mixBP:Bitmap;
private var mixBP2:Bitmap;
private var mixBD:BitmapData;
private var bdFilleRect:Rectangle= new Rectangle();

private var alwaysShow:Boolean = false;
private var isOn:Boolean = false;
private var _isHalf:Boolean = false;
private var _isMute:Boolean = false;

private var sinArr:Vector.<Number > ;
private var scaArr2:Vector.<Number > ;
private var toArr2:Vector.<Number > ;

private var bytes:ByteArray;
private var pus:Array;

private var filterRect:Rectangle;
private var filterPoint:Point = new Point(0,0);

private var _color:ColorChange=new ColorChange();
private var _transform:ColorTransform=new ColorTransform();
private var color:uint = 0xFFFF0000;


public function MixViewer()
{
sinArr = new Vector.<Number > (360,true);
filterRect = new Rectangle(0,0,256,80);
ins = this;
bytes = new ByteArray();
setTimeout(startThis, 1000);
for (var i:int=0; i<360; i++)
{
sinArr[i] = Math.sin(i/ 180* Math.PI);
}
pus = new Array();
pus.y = 50;
scaArr2 = new Vector.<Number > (512,true);
toArr2 = new Vector.<Number > (512,true);
for (var j:uint=0; j <512; j++)
{
scaArr2[j] = 1;
toArr2[j] = 1;
}
mixBP = new Bitmap(mixBD);
mixBP2 = new Bitmap(mixBD);
setTimeout(initMix, 1000);
addChild(mixBP);
mixBP.y = showH;
mixBP2.scaleY = -1;
mixBP2.y = showH;
addChild(mixBP2);
initValues();
MixViewer.stage.addEventListener(Event.RESIZE, onStageReSize);
MixViewer.stage.addEventListener(Event.ACTIVATE, onStageActive);
MixViewer.stage.addEventListener(Event.DEACTIVATE, onStageDeActive);
addEventListener(Event.ADDED_TO_STAGE, onStageReSize);
}


private function active():void
{
alwaysShow = ! alwaysShow;
}



private function initMix():void
{
//mixBP.alpha = .8;
onOff();
}

private function onStageActive(_arg_1:Event):void
{
isOn = true;
}
private function onStageDeActive(_arg_1:Event):void
{
isOn = false;
}
private function onStageReSize(event:Event=null):void
{
showW = int(MixViewer.stage.stageWidth * visScale);
showH = int(MixViewer.stage.stageHeight / 2 * visScale);
halfShowW = showW / 2;
if (mixBD)
{
mixBD.dispose();
}
mixBD = new BitmapData(showW,showH,true,0);
mixBP.bitmapData = mixBD;
mixBP2.bitmapData = mixBD;
mixBP.y = showH / visScale;
mixBP2.y = showH / visScale;
mixBP.scaleY = 1 / visScale;
mixBP.scaleX = 1 / visScale;
mixBP2.scaleY = 1 / visScale;
mixBP2.scaleX = 1 / visScale;
mixBP2.scaleY =  -  mixBP2.scaleY;
lineScaleValue = showW / 200 / visScale;
if (visScale == 1)
{
mixBP2.smoothing = false;
mixBP.smoothing = false;
}
else
{
mixBP2.smoothing = true;
mixBP.smoothing = true;
}
initValues();
}
private function startThis():void
{
addEventListener(Event.ENTER_FRAME, updateMix);
}
private function onOff():void
{
isOn = true;
}

private function initValues():void
{
filterRect = new Rectangle(0,0,showW,showH);
}

private function updateMix(event:Event):void
{
var n:int = 0;
var k:int = 0;
var m:int = 0;
var stpo:int = 0;
if (isOn == true|| alwaysShow == true)
{
color = 0xFFFF0000;
for (n = 0; n <512; n++)
{
scaArr2[n] = scaArr2[n] + (toArr2[n] - scaArr2[n]) / speedA;
}

mixBD.lock();
mixBD.fillRect(filterRect, 0xFFFFFF);

for (n = halfShowW + 1; n < showW; n +=  2)
{
k =showH * scaArr2[int(n / showW * 512)];
for (m = 0; m < k; m+=2)
{
if (m < showH)
{
mixBD.setPixel32(n, m, color + int(m / k * 256) * 16777216);
}

}
mixBD.setPixel32(n,k, color);

}

mixBD.applyFilter(mixBD, filterRect, filterPoint,new BlurFilter(2,2,1));
mixBD.colorTransform(filterRect, new ColorTransform(1,1,1,0.975));
for (n = 0; n < halfShowW; n+=2)
{
k = showH * scaArr2[int(n / showW * 512)];
for (m = 0; m < k; m+=2)
{
if (m < showH)
{
mixBD.setPixel32(halfShowW - n + m * xl, m, color);
}
}
mixBD.setPixel32(halfShowW - n, k, color);
}

/*****************弧线**************/
ange +=speedLine +(((scaleB * (scaArr2[5] + scaArr2[10] + scaArr2[15] + scaArr2[20] + scaArr2[25] + scaArr2[30] + scaArr2[35] + scaArr2[40] + scaArr2[45] + scaArr2[50] + scaArr2[55] + scaArr2[60] + scaArr2[70] + scaArr2[90] + scaArr2[110] + scaArr2[130] + scaArr2[150] + scaArr2[170] + scaArr2[190] + scaArr2[210] + scaArr2[230])) / 21) * (1 + (Math.random() * 10))) / 2;
stpo +=  1;
if (stpo > 9)
{
stpo = 0;
}
for (n = 0; n < showW; n+=3)
{
mixBD.setPixel32(n +stpo / 3, (sinArr[int((n / lineScaleValue + ange)) % 360] * showH) / 2 + showH / 2, color);
}


mixBD.unlock();
}

/*****************bytes********************/
frameCount +=  1;
if (frameCount == 2)
{
SoundMixer.computeSpectrum(bytes, true, 2);

for (n = 0; n <512; n++)
{
toArr2[n] = bytes.readFloat() * scaleA;
}
frameCount = 0;
}

/******************颜色变换*****************/
_color.enterFrameHandler();
_transform.color = _color.color_number;
//_transform.color =0x9900cc
this.transform.colorTransform = _transform;

}


}
}

class ColorChange
{
private var colorNumber:Number = 0xf09000;
private var colorArray:Array;
private var color_index:Number = 1;
private var mz:int = 1;
public function ColorChange()
{
colorArray = color_arr();
}
public function enterFrameHandler():void
{
var i:Number;
var j:Number;
i = Math.random();
if (i> 0.99)
{
mz *=  -1;
}
j = Math.round(mz * i * 5);
color_index +=  j;
if (color_index < 0)
{
color_index = colorArray.length - 1;
}
else
{
if (color_index >= colorArray.length)
{
color_index = 0;
}
}
colorNumber = colorArray[color_index];
}

private function color_arr():Array
{
var n:int = 0;
var color1:Array = [];
var color2:Array = [];
var color3:Array = [];
var color4:Array = [];
var color5:Array = [];
var color6:Array = [];
var color7:Array;
while (n < 0xFF)
{
color1.push(0xFF0000 + n * 256);
color2.push((0xFF - n) * 65536 + 0xFF00);
color3.push(0xFF00 + n);
color4.push((0xFF - n) * 256 + 0xFF);
color5.push(0xFF + n * 65536);
color6.push(0xFF - n + 0xFF0000);
n +=  3;
}
color7 = [];
color7 = [].concat(color1).concat(color2).concat(color3).concat(color4).concat(color5).concat(color6);
return color7;
}

public function get color_number():Number
{
return colorNumber;
}
}
  评论这张
 
阅读(21)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017