我正在使用 ActionScript 3.0 开发 mp3 播放器,下面是我的代码:
var my_songs:XMLList;
var my_total:Number;
var my_sound:Sound;
var my_channel:SoundChannel;
var current_song:Number = 0;
var myXMLLoader:URLLoader = new URLLoader();
myXMLLoader.load(new URLRequest("music/shakira.xml"));
myXMLLoader.addEventListener(Event.COMPLETE, processXML);
function processXML(e:Event):void
{
var myXML:XML = new XML(e.target.data);
my_songs = myXML.SONG;
my_total = my_songs.length();
playSong(0);
}
function playSong(mySong:Number):void
{
var myTitle = my_songs[mySong]. @ TITLE;
var myArtist = my_songs[mySong]. @ ARTIST;
var myURL = my_songs[mySong]. @ URL;//title_txt.text = myTitle;
// artist_txt.text = myArtist;
if (my_channel)
{
my_channel.stop();
}
my_sound = new Sound();
my_sound.load(new URLRequest(myURL));
my_channel = my_sound.play();
}
// next_btn.addEventListener(MouseEvent.CLICK, onNext);
// function onNext(e:MouseEvent):void {
// current_song++;
// if (current_song>=my_total){
// current_song=0;
// }
// playSong(current_song);
// }
我有一个输出错误:
TypeError:错误#1010:术语未定义且没有属性。
在 musicplayer_fla::MainTimeline/playSong()
在 musicplayer_fla::MainTimeline/processXML()
在 flash.events::EventDispatcher/dispatchEventFunction()
在 flash.events::EventDispatcher/dispatchEvent()
在 flash.net::URLLoader/onComplete( )