Volume level on button in flash
i want to control sound in my movie clip by t开发者_运维百科he button which i designed in flash. for ex.: my default sound is 100% on home button & when i click on contact(last button) the volume level goes to 20% same as in between buttons.
i use this script to call the sound in flash
bgSound = new Sound(this); bgSound.attachSound("sound1"); bgSound.start(0,99);
now tell me what i put in buttons to manage sound level.
Please help me.
Thanks
I assume your using AS2 based on the method calls shown, also based on that assumption did a quick google search and came back with this:
bgSound.setVolume(20);
http://www.actionscript.org/resources/articles/49/1/Volume-Slider-attachSound-method/Page1.html
If you are using another version of the language and I'm wrong here please let me know and I'll try to correct.
Ok i got it ( i hope ) , here you are I will go from ground zero
Download as2 version of TweenMax http://www.greensock.com/tweenmax/
Put com folder in same folder with ur project fla file
use this at top of your first frame which include rest of your code
import com.greensock.*;
Use this code to tween between target volumes
TweenMax.fromTo(bgSound,1,{volume:bgSound.getVolume},{volume:TARGETVOLUME)});
TARGETVOLUME is number between 0-100 in actionscript 2 for example if you want to change sound to 60 when u go to services put this in ur onRelease
TweenMax.fromTo(bgSound,1,{volume:bgSound.getVolume},{volume:60)});
And remember if u include actions on buttons ( which as2 allow ) target objects truly
If u can't tell me to provide a sample for u ;) Also u can do it with out tweenmax with events like enterframe but tweenmax is awsome hope u get to it and use it for many other features which save u a lot of time
精彩评论