2013-01-09 107 views
0

我有這個小片的AS3代碼,它不工作:(AS3型未發現:聲音

var snd:Sound = new Sound(new URLRequest("Hit1.wav")); 
var channel:SoundChannel = new SoundChannel(); 
channel= snd.play(); 

我得到的是

type was not found or was not a compile-time constant: Sound 
type was not found or was not a compile-time constant: SoundChannel 

如何解決這個

帆布

+1

你導入這些類? – inhan

+0

可能不是,但我找不到我需要的那些。我所有的是 \t import flash.display.MovieClip; \t import flash.utils.Timer; \t import flash.events.TimerEvent; \t // \t import flash.events.TouchEvent; – Canvas

回答

3

您必須導入類:

import flash.media.Sound; 
import flash.media.SoundChannel; 

或者只是:

import flash.media.*; 
+0

調用可能未定義的方法URLRequest ??? – Canvas

+1

在livedocs中,你會發現所有的包都有相應的類。 –

+0

@Canvas您還必須導入flash.net.URLRequest正如Florian所說,檢查文檔以確定您必須導入的內容,例如, http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/net/URLRequest.html –