2011-02-04 70 views
0

我正在嘗試爲我正在處理的網站設置音頻播放器,並且一直運行到此錯誤2032. .swf與我的歌曲列表文件一起位於我的主文件夾中。歌曲文件本身位於名爲歌曲的子文件夾中/閃存MP3播放器拋出錯誤2032 - 思考URLRequest是罪魁禍首?

我不確定可能會導致此情況,並且任何輸入都會有幫助。

<fx:Script> 
    <![CDATA[ 
     import mx.collections.ArrayCollection; 
     import mx.collections.ArrayList; 
     import mx.collections.XMLListCollection; 
     import mx.controls.Alert; 
     import mx.rpc.events.FaultEvent; 
     import mx.rpc.events.ResultEvent; 
     import mx.utils.ArrayUtil; 
     private var sound:Sound;      // Mp3 File 
     private var soundChannel:SoundChannel;   // Reference to playing channel 
     private var pausePosition:Number;    // Current play position (time) 
     private var percent:Number;      // Current played percentage 
     private var isPlaying:Boolean = false;   // Is the mp3 playing? 
     private var isLoaded:Boolean = false;   // Is the mp3 loaded? 
     //private var updateSeek:Timer = new Timer(500); // Timer for updating the seek bar 
     private var currentSong:String; 
     private var index:int; 
     private var start:Boolean = true; 
     private var songs:Array; 

     private function init():void { 
      grabSongs(); 
     } 

     private function grabSongs():void{ 
      var theLoader:URLLoader = new URLLoader(); 
      var theRequest:URLRequest = new URLRequest("songlist.txt"); 
      theLoader.load(theRequest); 
      theLoader.addEventListener(Event.COMPLETE, loadComplete); 
     } 
             

     private function loadComplete(theEvent:Event):void{ 
      songs = theEvent.target.data.split("\n"); 
      currentSong = songs[0]; 
      index = 0; 
     } 

     private function playPause(e:Event = null):void { 
      // Song playing? 
      if(isPlaying) { 
       // Save the current position in the track, stop playback, change button icon 
       pausePosition = soundChannel.position; 
       soundChannel.stop(); 
       this.btnPlay.label = "Play"; 
       // If the URL has been changed but not loaded, hide seekbar 
       // Song is not playing? 
      } else { 
       if(!isLoaded) { 
        // If the song isn't loaded yet, set up a new sound load request 
        if(start == true){ 
         start = false; 
        } 
        sound = new Sound(); 
        sound.load(new URLRequest("songs/" + currentSong)); 
        // Add an event listener to check for song load complete event 
        sound.addEventListener(Event.COMPLETE, songLoaded); 
        this.btnPlay.label ="Pause"; 
       } else { 
        // The song IS loaded, so play it 
        soundChannel = sound.play(pausePosition); 
        this.btnPlay.label = "Pause"; 
       } 
      } 
      // Regardless of playing state, change it now to the opposite 
      isPlaying = !isPlaying; 
     } 

     private function songLoaded(e:Event):void { 
      // Remove load event listener 
      sound.removeEventListener(Event.COMPLETE, songLoaded); 

      // Play the song 
      soundChannel = sound.play(0);    
      // Song is loaded 
      isLoaded = true; 
     } 

     private function prev(e:Event = null):void { 
      if(start == false){ 
       if(index == 0){ 
        index = songs.length - 1; 
       }else{ 
        index--; 
       } 
       currentSong = songs[index]; 
       isPlaying = true; 
       isLoaded = false; 
       playNew(e); 
      } 
     } 


     private function next(e:Event = null):void { 
      if(start == false){ 
       if(index == songs.length - 1){ 
        index = 0; 
       }else{ 
        index++; 
       } 
       currentSong = songs[index]; 
       isPlaying = true; 
       isLoaded = false; 
       playNew(e); 
      } 
     } 

     private function playNew(e:Event = null):void { 
      soundChannel.stop(); 
      sound = new Sound(); 
      sound.load(new URLRequest("songs/" + currentSong)); 
      // Add an event listener to check for song load complete event 
      sound.addEventListener(Event.COMPLETE, songLoaded); 
      this.btnPlay.label = "Pause"; 
     } 

    ]]> 
</fx:Script> 

<s:Button id="btnPrev" label="Previous" chromeColor="#000000" focusColor="#000000" color="#8D1111" enabled="true" click="{prev(event)}" height="20" width="80" x="0" y="0"/> 
<s:Button id="btnPlay" label="Play" chromeColor="#000000" focusColor="#000000" color="#8D1111" enabled="true" click="{playPause(event)}" height="20" width="80" x="81" y="0"/> 
<s:Button id="btnNext" label="Next" chromeColor="#000000" focusColor="#000000" color="#8D1111" enabled="true" click="{next(event)}" height="20" width="80" x="162" y="0"/> 

這在當地適用於我的筆記本電腦,但是當我將SWF文件上傳它拋出錯誤2032

感謝

更新

所以設置是完全一樣的FlexFiend回答,與http://localhost/FlexStuff/songs/我試圖檢查Flash調試器的日誌文件一起,這是我的消息:

錯誤#2032:流式傳輸錯誤。 URL:http://www.mywebsite.com/framework_4.0.0.14159.swf

我很不熟悉這是什麼意思,但也許它造成我的問題?

+0

你有`songlist.txt`(和其他所有)在同一個文件夾在本地機器上?哪一行導致`錯誤2032:流錯誤`和什麼時候? – www0z0k 2011-02-04 06:02:57

回答

0

驗證「songlist.txt」的路徑在本地服務器上。如果它位於遠程服務器上,則必須調查跨域問題。但是,如果是這樣的話,它甚至不會嘗試閱讀它,而是會讓你知道我假設的違反政策的行爲。

「songlist.txt」文件應與您在服務器上訪問的swf位於同一目錄中。即

http://localhost/FlexStuff/Swfalicious.html (the wrapper) 
http://localhost/FlexStuff/songlist.txt 
http://localhost/FlexStuff/Swfalicious.swf (the actual swf file) 
0

所以設置是完全一樣的FlexFiend 回答,與 http://localhost/FlexStuff/songs/我試圖檢查Flash調試器的日誌 文件一起,這 是我的消息:

錯誤#2032:流錯誤。網址: http://www.mywebsite.com/framework_4.0.0.14159.swf

我很熟悉一下這個 手段,但也許它導致我 問題?

的「framework_4.0.0.14159.swf」是約6 SWF文件,我顯然已經同時上傳到我的服務器得到這個swf文件的工作......我沒想到是一個必要?? 一旦上傳,但它確實有效。這是真的很奇怪,因爲我的印象我只需要上傳我創建的SWF,而不是一堆輔助文件...

相關問題