AS3 Sound bug with channel.pan
var snd:Sound = new Sound(); snd.load(new URLRequest("sample.mp3")); var ch:SoundChannel = snd.play(); var st:SoundTransform = ch.soundTransform; st.pan = 1; ch.soundTransform = st; trace(st.pan); trace(ch.soundTransform.pan); st.pan = -1; ch.soundTransform = st; trace(st.pan); trace(ch.soundTransform.pan);
Output:
1
1
-1.0000000000000004
-0.9880999999999998
You can clearly see me set the pan to 1 and then -1. But, if you notice, the -1 pan is a bit below -1 on the transform, but when you apply the transform to the channel, it goes above -1.
Update: Unfortunately, it looks like even if you set the pan all the way in one direction or the other, it doesn't actually work. You can still hear the sound coming out of the side that it is panned away from. So, I guess this bug is moot since pan doesn't actually work properly anyway.
How many more bugs are there in the Sound class?
August 10th, 2008 at 11:44 pm
SoundTransform::pan ist just a shortcut wrapper for leftToLeft/Right and vice versa. Unfortunately without private property (which could reflect real value):
public function get pan():Number{
if ((((this.leftToRight == 0)) && ((this.rightToLeft == 0)))){
return ((1 - (this.leftToLeft * this.leftToLeft)));
};
return (0);
}
If you want exact values use leftTo-/rightTo- properties.