2013-03-01 30 views
0

我在Haxe播放聲音資產時遇到問題。我能夠與swfmill進口的MP3沒有錯誤:在Haxe使用聲音資產

<?xml version="1.0" encoding="utf-8" ?> 
<movie width="100" height="100">  
    <frame>  
     <library> 
      ... other resources ... 
      <sound id="Shoot" import="shoot.mp3"/> 
     </library> 
    </frame>  
</movie> 

在我Main.hx,我創建了一個名爲Shoot類中我用我的.png資源以同樣的方式延伸Movieclip。然後,我使用這個類,如下所示:

var sound:MovieClip = new Shoot(); 
stage.addChild(sound); 
sound.play(); 

但在運行時,該代碼執行的時候,我得到的錯誤

"Error #2136: The SWF File <project swf> contains invalid data". 

任何明顯的失誤,我做我的SWF XML文件或haXe的碼?我怎樣才能進一步調試這個錯誤?

回答

0

我終於設法通過聲明爲聲音(而不是影片剪輯)

class Shoot extends flash.media.Sound {public function new() { super(); }} 

從庫中播放的聲音和你不需要將其添加到舞臺上,只是玩:

var shoot : flash.media.Sound = new Shoot(); 
shoot.play();