Skip to main content
Inspiring
April 18, 2013
Answered

Sound Transform not working

  • April 18, 2013
  • 1 reply
  • 586 views

Hey guys,

I'm getting this silly little problem. I'm making a sound play and I'm trying to change it's volume. I've done this many times before and got it to work, but in this script for some reason it's not working. The script looks like this :

package {

    import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.media.SoundTransform;

    public class Main

    {

        var createSound:Create;

        var createChannel:SoundChannel;

        var createTransform:SoundTransform;

        public function Main()

        {

            createSound = new Create();

            createChannel = new SoundChannel();

            createTransform = new SoundTransform();

            createTransform.volume = 0.5;

            createChannel.soundTransform = createTransform;

            createChannel = createSound.play();

        }

    }

}

For some reason, it plays the sound, but at full volume no matter what value I put in the createTransform.volume variable. I've gotten almost the same exact code working in other games I've made, I dunno why it isn't working in this one

This topic has been closed for replies.
Correct answer kglad

try:

package {

    import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.media.SoundTransform;

    public class Main

    {

        var createSound:Create;

        var createChannel:SoundChannel;

        var createTransform:SoundTransform;

        public function Main()

        {

            createSound = new Create();

            createChannel = new SoundChannel();

            createTransform = new SoundTransform();

            createTransform.volume = 0.5;

// in this order

            createChannel = createSound.play();

createChannel.soundTransform = createTransform;

        }

    }

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
April 18, 2013

try:

package {

    import flash.media.Sound;

    import flash.media.SoundChannel;

    import flash.media.SoundTransform;

    public class Main

    {

        var createSound:Create;

        var createChannel:SoundChannel;

        var createTransform:SoundTransform;

        public function Main()

        {

            createSound = new Create();

            createChannel = new SoundChannel();

            createTransform = new SoundTransform();

            createTransform.volume = 0.5;

// in this order

            createChannel = createSound.play();

createChannel.soundTransform = createTransform;

        }

    }

}

BawlarAuthor
Inspiring
April 18, 2013

haha I'm an idiot, thanks kglad!

kglad
Community Expert
Community Expert
April 18, 2013

(welcome to the club - and, you're welcome.)