Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-14-2004, 04:37 AM   #1
mjlavall
Registered User
 
Join Date: Feb 2004
Location: Michigan
Posts: 2
Default Sound Crossfader Question

I am making a cross fader for a flash program I am making. I want it to smoothly switch between two songs that are playing. When the slider is all the way to the left sound1 is playing at 100% volume and sound2 is at 0% volume, when the slider is on the right the are switched and when its in the middle they both play at 50%, with a smooth transition in between. I set up all the code just like in the volume slider tutorial on this site with the exception of two Sound objects, leftSound and rightSound, instead of one, and I removed the stop and play buttons. I then set the volume function with this code:



slider.slideBar.onEnterFrame = function() {

leftSound.setVolume(50-((this._x)/5));
rightSound.setVolume(50+((this._x)/5));

}



according to all my calculations this is correct. I entered the functions in my calculator to make sure they were correct for each value of x and they were…(the scene is 550px wide and the sliderbar is 50 px wide which is why this._x is divided by 5 to get 100)



Now the problem that occurs is when I test the movie both sounds take on the same volume. When the slider is on the left both sounds are mute but when it’s on the right both songs are 100% volume. And I have no clue why flash does this. Does anyone have any clue as to what is going on here.



Here is my complete ActionScript:



leftSound = new Sound(this);
rightSound = new Sound(this);
leftSound.attachSound("sound1");
rightSound.attachSound("sound2");
leftSound.start(0, 99);
rightSound.start(0, 99);
slider.slideBar._x = -250;
slider.slideBar.onEnterFrame = function() {

leftSound.setVolume(50-((this._x)/5));
rightSound.setVolume(50+((this._x)/5));

}

slider.slideBar.onPress = function() {

startDrag(this, false, -250, this._y, 250, this._y);

}

slider.slideBar.onRelease = slider.slideBar.onReleaseOutside=function () {

stopDrag();

}

stop();



I am completely stumped as to why this is happening, any help would be greatly appreciated.
mjlavall is offline   Reply With Quote
Old 02-14-2004, 06:02 AM   #2
mjlavall
Registered User
 
Join Date: Feb 2004
Location: Michigan
Posts: 2
Default Figured it out

Nevermind I figured it out.

For anyone else with this problem you need to attach your sounds to different movie clips. If they are attached to the same movie clip they will both be controlled no matter which one you specify.

I made two movieclips name sound1MC and sound2MC. I created the sound objects inside these movie clips and then referenced them as _level0.sound1MC.leftSound and _level0.sound1MC.rightSound.

This works great.
mjlavall is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
My brain hurts (onClipEvent question) andrea_levin ActionScript 2.0 3 03-25-2004 04:23 AM


All times are GMT. The time now is 10:48 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.