首页 > Flex/Flash

Flex3播放mp3例子

发表于2014-07-28 12:44:07| --次阅读| 来源webkfa| 作者小豆豆

摘要:Flex3播放mp3例子,非常方便,复制就可运行
flex代码
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" creationComplete="jbInit();">
	<mx:Script>
		<![CDATA[
			import mx.rpc.events.FaultEvent;
			import mx.rpc.events.ResultEvent;
			import mx.rpc.http.HTTPService;
			import mx.controls.Alert;
			var sound:Sound;
			var chan:SoundChannel;
			var so:SharedObject;
			function jbInit(){
			    sound = new Sound();
				var reg:URLRequest = new URLRequest("http://antiserver.kuwo.cn/anti.s?format=mp3&rid=MUSIC_4168456&response=res&type=convert_url");
				
				sound.addEventListener(Event.COMPLETE,loadNextSong);
				sound.load(reg,new SoundLoaderContext(3000, true));
				sound.addEventListener(IOErrorEvent.IO_ERROR,ioMethod);
				chan=sound.play(0);
			}
			public function resu(event:ResultEvent):void{
				Alert.show("result");
			}
			public function fault(event:FaultEvent):void{
				Alert.show("fail");
			}
			
			public function loadNextSong(event:Event):void{
				Alert.show("歌曲播完");
			}
			public function soundComplete(event:Event):void{
				Alert.show("sucee");
			}
			public function ioMethod(event:IOErrorEvent):void{
				Alert.show("Io");
			}
		]]>
	</mx:Script>
</mx:Application>

相关文章

猜你喜欢

学到老在线代码浏览器 关闭浏览
友情链接: hao123 360导航 搜狗网址导航 114啦网址导航 博客大全
Copyright © 1999-2014, WEBKFA.COM, All Rights Reserved  京ICP备14034497号-1