Copy link to clipboard
Copied
Hi, I am a newbie to ActionScript but I do have an understanding of scripting. I have worked in designing games on a few game engines and now I am looking into ActionScript 3.0
I created a script by getting some details here and there on the web and this is what Ive come up with,
var loadSnd:URLRequest = new URLRequest("Sound.wav");
var thisSnd:Sound = new Sound();
thisSnd.load(loadSnd);
Sound_1.addEventListener(MouseEvent.CLICK, playF);
function playF(event:MouseEvent);void{
thisSnd:play(); //Line 8
}
Output:
| Scene 1, Layer 'Actions', Frame 1, Line 8 | 1084: Syntax error: expecting rightbrace before semicolon. |
I dont think this is a difficult error to fix but it is an issue for me at the moment.
you can't load a wav. use an mp3.
Copy link to clipboard
Copied
use:
var loadSnd:URLRequest = new URLRequest("Sound.wav");
var thisSnd:Sound = new Sound();
thisSnd.load(loadSnd);
Sound_1.addEventListener(MouseEvent.CLICK, playF);
function playF(event:MouseEvent);void{
thisSnd.play(); //Line 8
}
Copy link to clipboard
Copied
| Scene 1, Layer 'Actions', Frame 1, Line 8 | 1084: Syntax error: expecting colon before dot. |
| Scene 1, Layer 'Actions', Frame 1, Line 9 | 1084: Syntax error: expecting identifier before rightbrace. |
The output returned those two statements up there.
My piece of code isn't exactly efficent. I imagine there are errors that are difficult to spot. Perhaps writing a new script is a better idea?
Copy link to clipboard
Copied
another error in your code:
kglad wrote:
use:
var loadSnd:URLRequest = new URLRequest("Sound.wav");
var thisSnd:Sound = new Sound();
thisSnd.load(loadSnd);
Sound_1.addEventListener(MouseEvent.CLICK, playF);
function playF(event:MouseEvent):void{
thisSnd.play(); //Line 8
}
Copy link to clipboard
Copied
That fixed the Button.
Now Actionscript 3.0 is giving me the following error.
ArgumentError: Error #2068: Invalid sound.
at flash.media::Sound/play()
at Project_fla::MainTimeline/playF()[Project_fla.MainTimeline::frame1:8]
It looks like the sound I created doesn't exist.
Is there a certain folder I must place my sound Instance in?
Copy link to clipboard
Copied
you can't load a wav. use an mp3.
Copy link to clipboard
Copied
Oh, Ok thanks for the help.
Copy link to clipboard
Copied
you're welcome.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more