PDA

View Full Version : how do I set volume?



Daimz
June 8th, 2008, 02:26 PM
How to I set the volume of an mp3 when it first loads on to page? I'm not concerned about making a volume bar I just want to make the volume lower.

this is how I have set up my music at the moment:

var s:Sound = new Sound(new URLRequest("5.mp3"));
var sc:SoundChannel = s.play(0, 99);
sc.soundTransform = new SoundTransform(0.1,-0.2);

Garfty
June 8th, 2008, 02:40 PM
s.volume = int;

replace int with a number of your choice, try .3

Daimz
June 8th, 2008, 02:41 PM
thanx alot

Garfty
June 8th, 2008, 02:43 PM
no probs man, let me know if it works

Daimz
June 8th, 2008, 02:45 PM
it didn't work came back with this error.


Access of possibly undefined property volume through a reference with static type flash.media:Sound.

sc.volume = 0.3; is how i put it in.

Garfty
June 8th, 2008, 02:49 PM
try just .3, without the 0

Daimz
June 8th, 2008, 03:03 PM
still the same problem??

Garfty
June 8th, 2008, 03:04 PM
Any chance I could take a look at the files??

Daimz
June 8th, 2008, 03:18 PM
sure think man here a link.
http://www.arctosdesign.com/sound.zip

Garfty
June 8th, 2008, 03:23 PM
something's messed up with that man, tried opening it on my pc and my macbook

Daimz
June 8th, 2008, 03:31 PM
ok try this
http://arctosdesign.com/music.zip

Garfty
June 8th, 2008, 03:34 PM
Nope sorry man, what you using??

mac or pc?

Daimz
June 8th, 2008, 09:04 PM
mac and it still not working? ok ill put up fla and the song:
http://arctosdesign.com/sound.fla

http://www.arctosdesign.com/5.mp3

littlespex
June 8th, 2008, 09:54 PM
Try sending the SoundTransform object to the play function:



var s:Sound = new Sound(new URLRequest("5.mp3"));
var st:SoundTransform = new SoundTransform(0.3, -1);
var sc:SoundChannel = s.play(0, 99, st);

dthought
June 9th, 2008, 10:41 AM
Or you could try:


var st:SoundTransform = sc.soundTransform;
st.volume = volume;
sc.soundTransform = st;

Where volume is some number between 0.0 and 1.0 - whether you have a leading 0 in front of the decimal point is up to you - it's just for readability. Personally, I always prefer them because it makes seeing a number less than 1.0 easier :)