A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: play sound only on hover/mouseover

  1. #1
    Registered User
    Join Date
    Jun 2011

    play sound only on hover/mouseover

    flash cs5 v11, as3

    hi, i'm a photographer without any scripting knowlage trying to get some actionscript 3 running. i want to do many little animations with sound on one page. for not getting a complete sound mess i thought about playing only on hoover. i was lucky to mix up some as3 to get a sound playing only when you hover the animation.

    A invisible button on a layer above the movie frames controls via mouseover and mouseout the start and stop of the sound - problem here: sound runs totally uncontrolled and asynchronous to the frames of the animation.

    the animation: http://bit.ly/mc7uRu
    fla file: http://bit.ly/kyIxP1
    a screenshot: http://bit.ly/lLxc8q

    here is the code of the button:
    PHP Code:
    import flash.net.URLRequest;
    import flash.media.SoundChannel;


    snd = new Sound();
    chn = new SoundChannel();
    snd.load(new URLRequest("http://...filename.mp3"));
    this.chn snd.play(0,10);

    now i loaded the audio file into the library to put it into timeline to be able to control when the sound starts and ends.
    i wanted to set the volume of the movie at start to 0%
    at mouseover to 100%
    and on mouseout to 0% again ...
    but that's the part i seem to be stuck for ever

    do you have any quick hints for me??
    thank you so much!!

  2. #2
    Moderator enpstudios's Avatar
    Join Date
    Jun 2001
    Tampa, Fl.
    You need to use the SoundTransform Class:

    Actionscript Code:
    import flash.media.SoundTransform;

    var volumeControl:SoundTransform = new SoundTransform();

    volumeControl.volume = 0;
    chn.soundTransform = volumeControl;

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