2012-03-30 40 views
0

我收到此錯誤消息: col:4:錯誤:嵌入變量不能具有現有值。 錯誤指的是帶有「[Embed(source =」../bin/03Outside.mp3「)]」的行。 在第一個「[},有一個紅色的線(我相信這表明它是什麼是錯的)當我收到此消息時,向FlashDevelop添加聲音(mp3)?

這裏是我的代碼:!

package 
{ 
    import flash.display.Sprite; 
    import flash.events.Event; 
    import flash.media.Sound 

    /** 
    * ... 
    * @author Kendall Murray 
    */ 
    public class Main extends Sprite 
    { 

     public function Main():void 
     { 
      if (stage) init(); 
      else addEventListener(Event.ADDED_TO_STAGE, init); 
     } 

     private function init(e:Event = null):void 
     { 
      removeEventListener(Event.ADDED_TO_STAGE, init); 
      // entry point 
      [Embed(source = "../bin/03Outside.mp3")] 
      var mySound:Sound = new Sound(); 
      mySound.load(new URLRequest("03Outside.mp3")); 
      mySound.play(); 
     } 

    } 

} 

請幫忙,謝謝

回答

1

我敢肯定,你需要將聲音在不同的地方。

... 
public class Main extends Sprite 
{ 

    [Embed(source = "../bin/03Outside.mp3")]private var SndOutside:Class; 

    public function Main():void 
    { 
... 

另外,如果你使用的URLRequest,我不相信你需要將聲音......你可以做兩者任一。 取出嵌入式聲音和使用的URLRequest,或代替使用的URLRequest做這樣的事情:

var mySound:Sound = new SndOutside(); 
mySound.play(); 

如果你已經SndOutside嵌入式像我上面顯示。 看看:http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/media/Sound.html瞭解更多信息。

相關問題