A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: on mouse over fade in sound - how ?

  1. #1
    Senior Member
    Join Date
    Jul 2001
    Posts
    207

    on mouse over fade in sound - how ?

    hi all i have cd to introduce six songs

    what will be the code if i want on muse over on any picture of the songs album the sound will start with fade in effect

    and on mouse out the sound fade out and stop ??

  2. #2
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    you need to use a Sound Object.
    see - How to Fade a Sound Object Up or Down

    http://www.kennybellew.com/tutorial/

  3. #3
    Senior Member
    Join Date
    Jul 2001
    Posts
    207
    thx a lot for u i will visit it now

  4. #4
    Senior Member
    Join Date
    Jul 2001
    Posts
    207
    thx and i found a pgae to do something near what i want but when i try to edit the code i did not success

    this is the page if any one can help

    what i want is one button on mouse over then the sound will start fade in and if mouse out then it will fade out

    thx


    http://www.kennybellew.com/tutorial/fade.htm
    Last edited by flashy5; 11-08-2009 at 04:53 AM.

  5. #5
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    PHP Code:
    /*
    import your mp3 to the Library, give it a Linkage Identifier - myMP3
    add a button to the stage - give it an instance name - fadeBtn
    add this code to the main timeline, (same frame as the button)
    */

    this.createEmptyMovieClip("clip",1000);
    mySound = new Sound(clip);
    mySound.attachSound("myMP3");

    this.createEmptyMovieClip("FADEin",2000);
    this.createEmptyMovieClip("FADEout",3000);

    vol 0;
    inc 0.5;
    inc2 1;
    songPlay false;

    function 
    fadeIn(){
    FADEout.onEnterFrame null;
    mySound.setVolume(0);
    if(!
    songPlay) {
    mySound.start();
    songPlay true;
    }
    FADEin.onEnterFrame = function(){
    trace("fade in volume - "+vol)
    vol>100 vol=100 vol+=inc;
    vol==100 FADEin.onEnterFrame null null;
    mySound.setVolume(vol)
    }
    };

    function 
    fadeOut(){
    FADEin.onEnterFrame null;
    FADEout.onEnterFrame = function(){
    trace("fade out volume - "+vol)
    vol<vol=vol-=inc2;
    mySound.setVolume(vol);
    if(
    vol==0){
    FADEout.onEnterFrame null;
    mySound.stop();
    songPlay false;
    }
    }
    };

    fadeBtn.onRollOver = function(){
    fadeIn();
    };

    fadeBtn.onRollOut = function(){
    fadeOut();
    }; 
    hope this helps

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