[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Flash CS3 Volume slider - preserving volume

Posted on 2008-11-07
1
Medium Priority
?
459 Views
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?

thanks.
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;
 
track_mc.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN,dragSlider);
stage.addEventListener(MouseEvent.MOUSE_UP,stopSlider);
 
function dragSlider(event:MouseEvent):void {
event.target.startDrag(false,bounds);
addEventListener(Event.ENTER_FRAME,setVolume);
}
 
function stopSlider(event:MouseEvent):void {
track_mc.slider_mc.stopDrag();
removeEventListener(Event.ENTER_FRAME,setVolume);
}
function setVolume(event:Event):void {
trace(track_mc.slider_mc.x/widthPos);
ratio_volume = track_mc.slider_mc.x/widthPos;
soundVol.volume = ratio_volume;
revChan.soundTransform = soundVol;
revChan.soundTransform = soundVol;
 
}

Open in new window

0
Comment
Question by:lexshine
1 Comment
 

Accepted Solution

by:
lexshine earned 0 total points
ID: 22911775
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:

track_mc.slider_mc.x/100;

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

0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Sometimes you know that one object has a specific child in it, but you can't find the child. This happened to me when I was trying to code some actionScript to make a toolbar work with its embedded buttons.  My partner had created the toolbar usi…
I have been doing hardcore actionscripting for some time; and needless to say I have faced a lot of problems in just understanding others' code rather than understanding what the code executes. A programmer's life can become hell when there are a lo…
In this tutorial viewers will learn how to create a basic motion tween animation in Flash Open a new document in Flash: Draw/import an image: Press CTRL + F8 to convert it into a graphic symbol: Select a frame (how long you want the tween to last): …
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…
Suggested Courses
Course of the Month20 days, 9 hours left to enroll

867 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