import flash.display.Sprite;
import flash.net.URLRequest;
import flash.media.Sound;
import flash.media.SoundChannel;//控制应用程序中的声音
import flash.events.Event;
import flash.events.ProgressEvent;

var bar:Sprite =new Sprite();
bar.graphics.beginFill(0xff00bb);
bar.graphics .drawRect(0,0,350,20);
bar.graphics .endFill();
addChild(bar);
bar.x=75;
bar.y=350;
bar.scaleX=0;

var bar2:Sprite =new Sprite ();
bar2.graphics .beginFill (0x876542);
bar2.graphics .drawRect (0,0,350,20);
bar2.graphics .endFill ();
addChild(bar2);
bar2.x =75;
bar2.y =350;
bar2.scaleX =0;

var url:URLRequest =new URLRequest ("汪峰 - 青春.mp3")
var sound:Sound =new Sound();
sound.load(url);
var channel:SoundChannel =new SoundChannel ();
sound.addEventListener(ProgressEvent.PROGRESS,Progress);
sound.addEventListener(Event.COMPLETE,addSound);
addEventListener(Event.ENTER_FRAME,changeV);
function Progress(e:ProgressEvent):void
{
 bar.scaleX =e.bytesLoaded/e.bytesTotal;
}
function addSound(e:Event ):void
{
 channel =sound.play();
}
function changeV(e:Event ):void
{
 bar2.scaleX =channel.position /sound.length ;
}

posted on 2012-10-19 21:12  才美  阅读(117)  评论(0编辑  收藏  举报