Flash CS3 Volume slider - preserving volume

Posted on 2008-11-07
Last Modified: 2013-11-11
I am using this code to adjust volume using a fader.

It is working fine, but when I restart the audio, and do not recall this function, even though the fader stays in place at the correct position, the volume goes back to default until I touch the fader, then it pops back down to the fader position volume.

I have tried making all of the variables private, is there anyway of me preserving the volume level that the fader is at when the audio restarts?

private function VolumeSlider(){

soundVol = new SoundTransform();

trackBounds = track_mc.getBounds(track_mc);

xPos = trackBounds.x;

yPos = 0;//trackBounds.y;

widthPos = trackBounds.width-track_mc.slider_mc.width;

heightPos = 0;

bounds = new Rectangle(xPos,yPos,widthPos,heightPos);

track_mc.slider_mc.x = widthPos;

track_mc.mouseEnabled = false;

track_mc.slider_mc.buttonMode = true;



function dragSlider(event:MouseEvent):void {,bounds);



function stopSlider(event:MouseEvent):void {




function setVolume(event:Event):void {


ratio_volume = track_mc.slider_mc.x/widthPos;

soundVol.volume = ratio_volume;

revChan.soundTransform = soundVol;

revChan.soundTransform = soundVol;


Open in new window

Question by:lexshine
    1 Comment

    Accepted Solution

    I figured this out.

    What I did was remove this line:

    track_mc.slider_mc.x = widthPos;

    which was setting the default fader position, then used the following code:


    to track the fader position at all times. Then just used soundTransform at thos coordinates.


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    I come across a lot of question about how to access things in the document class from a movieclip, or accessing something from a movieclip in the document class. It took me a while to figure this out but once I did it makes life so much easier. …
    I have found that much of my time doing support ends up being a constant repetition of the same steps to different people.  Early on I stated using web pages with Frequently Asked Questions (FAQs) to alleviate most of the burden.  Sometimes this jus…
    The goal of the tutorial is to teach the user how to use the auto adjust feature and what the different options do. When your video is not working right you can choose the auto adjust feature to help choose your settings.
    The goal of the tutorial is to teach the user what frame rate is, how to control it and what effect it has on the video.

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now