2012-03-30 41 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了解更多信息。

相关问题