Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Adobe AIR Development

New Contributor
Posts: 3
Registered: ‎03-09-2011
My Device: Not Specified

Playing a sound

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.



var sound = new Sound();



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.

 at views:Smiley Very HappyrumTraxHome/button1_clickHandler()[C:\Users\John\Adobe Flash Builder Burrito Preview\DrumTrax\src\views\DrumTraxHome.mxml:10]

 at views:Smiley Very HappyrumTraxHome/___DrumTraxHome_Button1_click()[C:\Users\John\Adobe Flash Builder Burrito Preview\DrumTrax\src\views\DrumTraxHome.mxml:26]

I just have the wave files in the root directory. 
If anybody can help me out that would be great Smiley Happy




Posts: 345
Registered: ‎03-13-2011
My Device: Playbook
My Carrier: n/a

Re: Playing a sound

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


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.


Posts: 6,473
Registered: ‎12-08-2010
My Device: PlayBook, Z10
My Carrier: none

Re: Playing a sound


woollymammoth wrote:
var sound = new Sound();


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.

Peter Hansen -- (BB10 and dev-related blog posts at http://peterhansen.ca.)
Author of White Noise and Battery Guru for BB10 and for PlayBook | Get more from your battery!