AS3 Sound bug with channel.pan

August 7th, 2008 by Steven Sacks
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?

Posted in Bugs, Flash

One Response

  1. maliboo

    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.

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.

About Steven Sacks

I am a professional Flash developer with over 13 years of programming experience. I have consulted for high-profile agencies and companies in San Francisco, Los Angeles, Atlanta and New York, and developed numerous award-winning websites and rich internet applications for clients including Adobe, Fox Sports, FX Networks, Anheuser-Busch, GE, DirecTV, ESPN, The Weather Channel, Home Depot, and Coca-Cola.

I am the author of the open-source Gaia Framework for Adobe Flash, which dramatically reduces development time and makes developing Flash sites much easier.