A Flash Developer Resource Site

Results 1 to 10 of 10

Thread: timeline sync AND volume control?

  1. #1
    Junior Member
    Join Date
    Oct 2006
    Posts
    2

    timeline sync AND volume control?

    Hi

    I apologise if this is a very ignorant question... but...
    Is there a way to both have a voice over sound link to the timeline’s graphics
    (easily achieved by placing the sound in the timeline and choosing the 'stream' option?)
    But also be able to control its volume parameters?
    (which so far i only managed to do using sound symbols)

    to ask it properly-
    1. Is there a way to control a sound's volume when placing it in the timeline?
    Or
    2. is there a way to sync sound to timeline when using it as a sounds class- mysound:sound= new sound ();

    It weirdly seems like i have to choose one functionality or the other...
    am i right or simply unaware of an easy solution?

    help...

  2. #2
    Procrastinator
    Join Date
    Oct 2000
    Location
    Osaka
    Posts
    138
    Hi Yael,
    I have been trying to figure out the same thing. As far as I can tell, it does seem that you have to choose one or the other. Which is a bit rubbish. Unless someone knows better?...

  3. #3
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    You can control volume of sound placed on the timeline, but it will control the sound in the whole Flash movie.

    Code:
    allSound=new Sound();
    allSound.setVolume(0);

  4. #4
    Procrastinator
    Join Date
    Oct 2000
    Location
    Osaka
    Posts
    138
    Thanks rdoyle. I'm guessing that's 2.0 code, as it doesn't work in 3.0.
    Declaring the var helps but there doesn't seem to be a setVolume() method for the Sound class.

    Code:
    var allSound:Sound = new Sound();
    allSound.setVolume(0); // error
    The error description reads:
    "1061: Call to a possibly undefined method setVolume through a reference with static type flash.media:Sound."

  5. #5
    Registered User
    Join Date
    Apr 2001
    Location
    Akron OH, USA
    Posts
    4,841
    Not sure why you are getting errors.
    please review the sound class documentation. setVolume() is a supported method.

    Also a sound object will control sound for its associated movie clip if you pass the target path of the mc in the sound function. However, for timeline sounds, this is a heirachy, so any timeline sounds in nested mcs will be affected by their parent timeline's sound object.

    When you create a sound object on the root timeline, it will control volume of all sounds in that SWF file. But if you create a sound object associated with another mc then it will only control volume for timeline sounds in that mc, not all.

  6. #6
    Senior Member
    Join Date
    Apr 2002
    Posts
    2,849
    Ah, it's probably best to mention when you're using Actionscript 3, or post in the Actionscript 3 forum. But no big deal.

    To do the same thing in AS3:

    Code:
    var myTransform:SoundTransform=SoundMixer.soundTransform;
    myTransform.volume=0;
    SoundMixer.soundTransform=myTransform;

  7. #7
    Procrastinator
    Join Date
    Oct 2000
    Location
    Osaka
    Posts
    138
    Cheers for that, it works a treat .
    Sorry about the forum confusion. I was reluctant to start a duplicate thread on the same topic. Also wasn't sure which aspect of the question took precedence (as3 or sound) but will use as3 forum next time if it's in as3

  8. #8
    Junior Member
    Join Date
    Oct 2006
    Posts
    2

    thank you !!

    hey rdoyle720,
    took me a little to realise there was a reply to my old question,
    but this works great!!
    you star!
    thank you

  9. #9
    Junior Member
    Join Date
    Nov 2007
    Posts
    27
    I realize this is an old thread, but I'm having the same issue. It looks like the as3 reply above answers the question in establishing the variables, but how do I apply that to, say, a mute button? (Sorry, actionscript 3 newbie...)

  10. #10
    Junior Member
    Join Date
    Oct 2008
    Location
    Atlanta
    Posts
    3

    control timeline sound volume

    To use that to mute your sound, put that code inside of a function called by an mouse-click eventlistener attatched to your button....

    muteVol_btn.addEventListener(MouseEvent.CLICK, muteVolume);

    function muteVolume(evt:MouseEvent):void{
    var myTransform:SoundTransform=SoundMixer.soundTransfo rm;
    myTransform.volume=0; //mutes sound
    SoundMixer.soundTransform=myTransform;
    }

    you could make other buttons for other sound control...

    halfVol_btn.addEventListner(MouseEvent.CLICK, halfVolume);

    function halfVolume(evt:MouseEvent):void{
    var myTransform:SoundTransform=SoundMixer.soundTransfo rm;
    myTransform.volume=.5;
    /* volume is half as loud, change this number anything from 0 to 1 for mute to full sound */
    SoundMixer.soundTransform=myTransform;
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center