加载资源 — 音频

加载音频直接用flash.media.Sound类,它自身提供了加载机制:

package

{

	import flash.display.Sprite;

	import flash.events.Event;

	import flash.media.Sound;

	import flash.net.URLRequest;

	

	/**

	 * ...

	 * @author zhujl

	 */

	public class LoadSound extends Sprite

	{

		public var sound: Sound;

		

		public function LoadSound() 

		{

			sound = new Sound();

			sound.addEventListener(Event.COMPLETE, onLoadCompleted);

			sound.load(new URLRequest('1.mp3'));

		}

		

		public function onLoadCompleted(e: Event)

		{

			sound.play();

		}

	}

	

}

  

你可能感兴趣的:(加载)