2008/09/01

收到书了

收到了蓝色理想寄过来的 flex 书,书已是伤痕累累…
代码部分:
import flash.filters.BitmapFilter;
import flash.filters.BitmapFilterQuality;
import flash.filters.BitmapFilterType;
import flash.filters.GradientBevelFilter;
import flash.text.TextField;
import flash.text.TextFieldType;
import flash.display.Sprite;
stage.scaleMode = StageScaleMode.NO_SCALE;
var url:String = "sound.mp3";
var request:URLRequest = new URLRequest(url);
var s:Sound = new Sound();
s.addEventListener(ProgressEvent.PROGRESS, progressHandler);
s.addEventListener(Event.COMPLETE, completeHandler);
s.load(request);
var song:SoundChannel = s.play();
song.addEventListener(Event.SOUND_COMPLETE, soundCompleteHandler);
var ba:ByteArray = new ByteArray();
var gr:Sprite = new Sprite();
gr.x = 20;
gr.y = 200;
addChild(gr);
/*
var bgColor:uint = 0xCCCCCC;
var size:uint = 80;
var offset:uint = 50;
var distance:Number = 5;
var angleInDegrees:Number = 225; // opposite 45 degrees
var colors:Array = [0xFF0000, 0xFFFFFF, 0x000000];
var alphas:Array = [1, 0, 1];
var ratios:Array = [0, 128, 255];
var blurX:Number = 8;
var blurY:Number = 8;
var strength:Number = 2;
var quality:Number = BitmapFilterQuality.HIGH
var type:String = BitmapFilterType.INNER;
var knockout:Boolean = true;
var filter:BitmapFilter=new GradientBevelFilter(distance,
angleInDegrees,
colors,
alphas,
ratios,
blurX,
blurY,
strength,
quality,
type,
knockout);
*/
var bgColor:uint = 0xCCCCCC;
var size:uint = 80;
var offset:uint = 50;
var distance:Number = 0;
var angleInDegrees:Number = 45;
var colors:Array = [0xFFFFFF, 0xFF0000, 0xFFFF00, 0x00CCFF];
var alphas:Array = [0, 1, 1, 1];
var ratios:Array = [0, 63, 126, 255];
var blurX:Number = 50;
var blurY:Number = 50;
var strength:Number = 2.5;
var quality:Number = BitmapFilterQuality.HIGH;
var type:String = BitmapFilterType.OUTER;
var knockout:Boolean = false;
var filter:BitmapFilter=new GradientGlowFilter(distance,
angleInDegrees,
colors,
alphas,
ratios,
blurX,
blurY,
strength,
quality,
type,
knockout);

var farr:Array=new Array();
farr.push(filter);
var time:Timer = new Timer(50);
time.addEventListener(TimerEvent.TIMER, timerHandler);
time.start();
function createTextField(x:Number, y:Number, width:Number, height:Number):TextField {
var result:TextField = new TextField();
var format:TextFormat = new TextFormat();
format.font = "Verdana";
format.color = 0xFF0000;
format.size = 10;
result.defaultTextFormat = format;
result.x = x;
result.y = y;
result.width = width;
result.height = height;
addChild(result);
return result;
}
var loading:TextField = createTextField(0, 20, 200, 20);
var loadstr:String;
function progressHandler(event:ProgressEvent):void {
loadstr=String(Math.floor((event.bytesLoaded/event.bytesTotal)*100));
loading.text=loadstr;
trace(loadstr);
//trace(" bytesLoaded=" + event.bytesLoaded + " bytesTotal=" + event.bytesTotal);
}
function completeHandler(event:Event):void {
//loading.visible=false;
//s.removeEventListener(ProgressEvent.PROGRESS, progressHandler);
event.target.play();
}
function soundCompleteHandler(event:Event):void {
time.stop();
}
function timerHandler(event:TimerEvent):void {
SoundMixer.computeSpectrum(ba, true);
var i:int;
gr.graphics.clear();
gr.graphics.lineStyle(0, 0xFFFFFF);
gr.graphics.beginFill(0xFFFFFF);
gr.graphics.moveTo(0, 0);
var w:uint = 2;
for (i=0; i<512; i+=w) {
var t:Number = ba.readFloat();
var n:Number = (t * 100);
gr.graphics.drawRect(i, 0, w, -n);
gr.filters=farr;
}
}

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home