03-15-2011 10:59 PM
Hi I have a music app all ready to go I just can't seem to play the sound. I have been looking at the forums an aparently you cannot hear the sound in the emulator. Also is the the right code because it gives me an error.
When I try to play it it gives me this error.
ReferenceError: Error #1069: Property attachSound not found on flash.media.Sound and there is no default value.
03-15-2011 11:21 PM
Sound works as of 0.9.4 (Also I think it worked in 0.9.2 but that was before my time).
Here is how to play a mp3 file:
// Load the sound var mySound:Sound = new Sound(); mySound.load(new URLRequest("myMP3.mp3")); // Play it mySound.play();
Also you may want to look into SoundTransform and SoundChannel so you can play more sounds at the same time and control the volume but you should be able to check the documentation for that information.
03-16-2011 12:15 AM
var sound = new Sound();sound.attachSound("Kick");sound.play;
This isn't valid. Check the docs for flash.media.Sound. There is no such function/property as "attachSound".
Also, although there is a function "play", in ActionScript you have to actually invoke functions by using () rather than just naming the function like that (as far as I know), so sound.play() is the way to do it.