Actionscript 1&2: Buttons that fade music out or in.

This is a real general question but I'll explain what I'm trying to ask for.
I'm trying to make a button that when you press it, you continue on to the next "scene." I know how to do that now.
I also want music to play when clicking the button but the issue remains, how will the music keep up if the user is pressing it too soon? I don't want it to end abruptly so I need a code that fades the music out (or in).
So what code am I looking for?

you need to create a loop (like onEnterFrame) that decreases the volume of your sound with each loop iteration.  terminate the sound when not needed.

Similar Messages

  • HELP PLZ!! Array Button Menu that fades in/out content with Tweener or Tween Class...!!!

    OK.
    So I've been trying the last couple of days to make 2 different codes i had into one...
    The first on is using the Tweener class and everytime that I press a button it fades out the loaded content of the previous selection, waits for it to finish and then loads the content of the button pressed. Everything works fine with this part.
    The second code is the on that is using an Array to dynamicaly rollover, rollout and keep selected the buttons.
    It was also changing the content of the mc that everything is loaded on but without this fancy fade in - fade out...!!
    So i think its time for some code now...:
    Here are 2 different approaches:
    This is the code that uses the onMotionFinished of the Tween Class:
    var groupinfo:Array = [ {mc:about, toload:"mcHome"},
         {mc:service, toload:"mcService"},
         {mc:contact, toload:"mcContact"}];
    var activebtn:MovieClip;
    var holder1:MovieClip = _root.attachMovie("mcHome", "mcMain", 10);
    holder1._x = 0;
    holder1._y = 110;
    function doClick() {
    //          \/THE PROBLEM IS FROM HERE\/
         if (this != activebtn){
              var mcTween:Tween = new Tween(mcMain, "_alpha", Strong.easeOut, 100, 0, 1, true);
              mcTween.onMotionFinished = function() {
                   _root.holder1.attachMovie(this.p, "mcMain", 1);
                   var mcTween2:Tween = new Tween(mcMain, "_alpha", Strong.easeOut, 0, 100, 10, true);
    //          /\UNTIL HERE/\
         var prevbtn:MovieClip = activebtn;
         activebtn = this;
         this.gotoAndStop(FADEINSTOP);
         prevbtn.onRollOut();
    function init() {
       for (var element in groupinfo) { 
          // btn is a pointer to one of the nav buttons
          var btn:MovieClip = groupinfo[element].mc;      
          // have each button remember which library/mc it is supposed to load
          btn.p = groupinfo[element].toload;      
          // assign functions to each event
          btn.onRollOver = doRollOver;
          btn.onRollOut = doRollOut;
          btn.onRelease = doClick;
    init();
    And the Example:
    The onMotionTween code works ok with the tweening but doesn't change the movieclip.
    This is the code that uses the caurina Tweener Class with no onMotionFinished:
    var groupinfo:Array = [{mc:about, toload:"mcHome"},
                                {mc:service, toload:"mcService"},
                                {mc:contact, toload:"mcContact"}];
    var activebtn:MovieClip;
    var holder1:MovieClip = _root.attachMovie("mcHome", "mcMain", 10);
    holder1._x = 0;
    holder1._y = 110;
    function doClick() {
    //          \/PROBLEM FROM HERE\/
         if (this != activebtn) {
              Tweener.addTween(mcMain,{_alpha:0, time:1, transition:"easeOutQuart"});
              var holder2:MovieClip = _root.attachMovie(this.p, "mcMain2", 11);
              holder2._alpha = 0;
              holder2._x = 0;
              holder2._y = 110;
              Tweener.addTween(mcMain2,{_alpha:100, time:1, delay:1, transition:"easeOutQuart"});         
              mcMain = mcMain2;
    //           /\TO HERE!!!/\
         var prevbtn:MovieClip = activebtn;
         activebtn = this;
         this.gotoAndStop(FADEINSTOP);
         prevbtn.onRollOut();
    function init() {
         for (var element in groupinfo) {
              // btn is a pointer to one of the nav buttons
              var btn:MovieClip = groupinfo[element].mc;
              // have each button remember which library/mc it is supposed to load
              btn.p = groupinfo[element].toload;
              // assign functions to each event
              btn.onRollOver = doRollOver;
              btn.onRollOut = doRollOut;
              btn.onRelease = doClick;
    init();
    Other Example:
    The Tweener code works perfectly this first time but the second time removes the conent and does just the fade in.
    The code for the buton group i got it from                     here...
    Please could someone help me with this thing!!
    I think its a great piece of dynamic code if we can eventualy make it  work properly!!
    Thanksss!!!
    Shorten the code...  Left only the part that needs mod!!

    clbeech, Thank you but doesnt do anything either....!!It is a  bit usefull but... !!
    The problem is that the code cant give the "this.p" to the movieclip...
    Here is the mess i've made with few changes from your part... and alot of treces to wich detected that the this.p is can't get in the onMotionFinished function...
    its only the doClick function:
    function doClick() {
         trace ("---------vars after click----------")
         trace ("activebtnStart  "+  activebtn);
         trace ("this.p  OutPre:  " + this.p);
         if (this != activebtn){
              trace ("mcMainAlphaBefore:  " + mcMain._alpha);
              trace ("mcMainBefore:  " + mcMain);
              var mcTween:Tween = new Tween(mcMain, "_alpha", Strong.easeOut, 100, 0, 1, true);
              mcTween.onMotionFinished = function() {
                   holder["mcMain"].removeMovieClip();
    //               trace ("mcMainStart:  " + mcMain);
    //               trace ("mcMain2Start:  " + mcMain2);
    //               trace ("mcMainAlphaStart:  " + mcMain._alpha);
    //               trace ("mcMain2AlphaStart:  " + mcMain2._alpha);
                   trace ("this:  " + this);
                   trace ("this.p  Pre:  " + this.p);
                   holder.attachMovie(btn.p, "mcMain", 1);
                   holder.alpha = 0;
                   trace ("this.p  After:  " + this.p);
    //               mcMain = mcMain2;
                   new Tween(mcMain, "_alpha", Strong.easeOut, 0, 100, 10, true);
    //               mcMain._alpha = 100;
    //               trace ("mcMainEnd:  " + mcMain);
    //               trace ("mcMain2End:  " + mcMain2);
    //               trace ("mcMainAlphaEnd:  " + mcMain._alpha);
    //               trace ("mcMain2AlphaStart:  " + mcMain2._alpha);
         trace ("this.p  OutAfter:  " + this.p);
         var prevbtn:MovieClip = activebtn;
         activebtn = this;
         this.gotoAndStop(FADEINSTOP);
         prevbtn.onRollOut();
         trace ("this.p  "+  this.p);
         trace ("this  "+  this);
         trace ("prevbtn  "+  prevbtn);
         trace ("activebtn  "+  activebtn);    
    Pfff.....
    I think its best to Attach the .fla!!
    Please have a look on it if you have anytime..!!
    Thanks for your interest..

  • Create buttons that fade in on MENU

    Like any comercial DVD, I'd like to be able to have my buttons fade in (not be seen before as a background movie first starts). Then at my desired time, i'd like to be able to have the button be selected and accessed. How do you specify this?
    I thought a work around would be to have the PLAY button right on the MOTION menu i created...but I wouldn't have the interactivity when selecting the Buttons, like underlining..etc.
    Thanks!
    -M

    You could certainly achieve this the way joey848 describes, but you should read up on setting the 'loop point' before you go any further.
    You need to construct the footage for the introduction and fade in all of the elements that you want to appear, including button texts, then hold this for at least 30 seconds as a still. Use FCP, Motion, AE, whatever you like. Take a frame out of this into Photoshop (or similar) and use it as a guide, and create an overlay pict file (as for a standard menu) which has the highlight shapes on it only (not the frame from the sequence). Import that into DVDSP along with your animated sequence.
    Use the sequence in a menu, and use the property inspector to set the loop point slider to a place just after the sequence becomes still. Add the overlay file, draw the button rectangles and set the targets and navigation as you would for a standard menu.
    What will happen is that the entire animated sequence will play and your fade will take place, then the buttons will be active. At the end of the menu the loop will occur - there will be a slight pause as this happens - and then the still section will continue on screen. If you want to go back to the menu and start at the loop point then you'll need to use a short script to do so. The details for this are in the DVDSP user manual.

  • How do I add a print button that would print out pdf or different version than what is on the site?

    I see this example on NY Times.  If you pick any of their articles and click print or do the short cut (Command-P) ... (Control-P for windows), the layout of their article is completely customized and cleaner.  It seems like they've edited the print look to be different than what you see on the website.
    I find that very cool and something I've bent dying to achieve.  My guess is that I could make a pdf to what I want the print look to be and have a print button read that instead of the website but I don't know, I need help with this.

    I have but it's not what I'm looking for.  I want to edit what the printer will actually print when a reader clicks print.  So if the page has a puzzle, for example, and the reader clicks print.  The printer will print the puzzle in a different location on the page without some of the clutter that's on the site or have some message that's not originally present on the website.

  • Need button to fade-out page (.swf) when pressed, open URL

    Hi-ya
    3 days going on 4 and i still haven't figured out how or what
    i need to do that would enable a button placed on a SWF (webpage),
    when clicked, will fade that .swf to blak,thereafter a URL opens
    (my homepage). does anyone know what i need to do in this case. my
    actionscript skills is graded at c or c -, so any help there would
    be appreciated.
    thanx,
    IfOnlyiNu
    From
    http://www.developmentnow.com/g/68_2004_9_0_15_0/macromedia-flash.htm
    Posted via DevelopmentNow.com Groups
    http://www.developmentnow.com

    Here is the theory - you should be able to figure it out from
    there:
    1. In your main movie create a new movieclip call it "Fade",
    make the first frame blank and put a stop(); action on it.
    2. On the second frame create a new graphic symbol bigger
    then the full screen and make it a full black square.
    3. Go a few frames ahead, the farther the longer the fade
    will take. Insert a keyframe.
    4. Go back to frame 2, select the black box graphic and make
    its alpha = 0%
    5. Create a tween on frame 2, this will make the box go from
    invisible to visible on the last keyframe.
    6. On the last frame where the box is totally black add the
    getURL("url") actionscript.
    7. Go back to the main scene of the movie and place the
    "fade" movieclip on the top layer. Since it is stopped on the first
    blank frame it will not be visible until something makes it play.
    8. Add an actionscript to the button that will start the
    fade, it will look like
    *buttoninstancename*.onRelease = function () {
    _root.Fade.gotoAndPlay(2);
    //this tells the movie fade to go to the second frame and
    play
    replace *buttoninstancename* with the instance name of the
    button on the stage that conrtols the fade.
    That will make the "Fade" movie play, which is a tween that
    turns the full screen to black, and then redirects to a new url at
    the end.
    Hope that helps.

  • How can I make a menu with button's that fade-in?

    I've built a motion menu in AE, and had added text layers/buttons that fade-in through layer>Encore>Create Button. Once I import this into Encore through dynamic link I cannot link the buttons to the motion menu.  I've added a sample.
    Basically all I want is the play feature, Scene selection ,and credits to be selectable after they finish fading in @ the :20 mark. I don't want the menu to loop either.
    I've tried to make a static menu(from last frame in AE) play after this, but, there is a one second gap or so before that static menu plays which just looks tacky. I have tried this in preview, and rendered it to a dvd with the same result.
    All the tutorials i've come across really don't answer this question either.  
    Any help would be appreciated.
    Thanks

    I believe that Jon Geddes has a TUTORIAL, that might also be useful to you.
    Sounds like you and Stanley have it worked out, but you might pick up an additional idea, or two.
    Good luck,
    Hunt

  • Help With Buttons to Fade In on Main Main

    Hi
    I am imported a video file I made is Motion. I need to know how I can make the buttons fade in on the last part of the main menu? it wont let me do so? When make the new buttons it just plays the through the whole thing, cant get the buttons to start a a certain point? Thanks T.

    http://dvdstepbystep.com/motion.php shows how to use Motion to make buttons that fade in.
    The fade in is done in the video itself, overlays start at loop point
    So you need to redo it a bit it sounds like

  • Make images fade in & out?

    Hi, we're redeveloping our application in swing (java 1.4.2).
    When the application is not in use it displays several images on the screen. We want these to smoothly fade in and out (not necessarily synchronised with each other) so as to be more visually appealing.
    Any recommendations on a good technique?
    We don't want to use animated gifs due to the 256-colour limit - is there a way to do this that isn't CPU-intensive? Something we can use with PNGs, for example?
    TIA
    Phil

    well perhaps you can override the paint method, which will change the opacity of the image...and maybe use some type of thread or timer to animate that fade in/out affect. Set change the opacity used by the Graphics2D object in a paint method do the following:
         * Set alpha composite.  For example, pass in 1.0f to have 100% opacity
         *  pass in 0.25f to have 25% opacity.
        private AlphaComposite makeComposite(float alpha) {
            int type = AlphaComposite.SRC_OVER;
            return (AlphaComposite.getInstance(type, alpha));
         public void paint(Graphics g) {
                  Graphics2D g2d = (Graphics2D) g;
                  g2d.setComposite(makeComposite(.25f));
                  // do some painting...
          }that should give you some idea.
    good luck!

  • Specific region mouse over effect(Button 1 fades out and Button 2 fades in).

    Dear All -
    I am new to Flash CS5 and building Flash navigation bar with buttons on it.
    Below is my problem description that I want to solve with your help.
    I have a rectangular bar and placed one small button(Button 1) on this bar. Also, I have similar button(Button 2) with some graphics on it which is of similar size as to previous Button 1.
    Button 1 - Without graphic.
    Button 2 - With graphic on it.
    What I want is that, whenever mouse is taken over Button 1 placed on the rectangular bar, it should fade out and simultaneously Button 2 should fade in. I want only button region to be sensitive to this mouse over effect and not the complete rectangular bar.
    Kindly let me know how can I define the specific region(button region only) to be sensitive to mouse over effect in flash, and how to place Button 1 and Button 2 in layers so that both are at the same positition(so that there is no displacement of button detected).
    Thank You,
    Saurabh Khanna.

    Hello -
    Thank you for the reply. Button 1 does not have glowing effect, whereas Button 2 has a glowing effect. So what I wanted is that when initially Button 1 is loaded during page load, when I mouse over Button 1, Button 1 would fade out and Button 2 sitting behind Button 1 would automatically look like fade in(due to gradual fad out of Button 1 on top of Button 2).
    I could do this now, and would like to Thank you for your reply.
    I did this by creating movie clip on "Over" event of Button 1 and changing its Alpha property. But now what I want is how to gradually fade out, means when I remove my mouse from over button, then Button 2 should fade out gradually which will automatically make Button 1 fade in gradually.
    I could not find the "Out" event just like we have "Over" event for Button, so I assume this can only be done using ActionScript somehow.
    Let me know if I am going correct with my assumption, and possibly if you could help me achieve the remaining half(fading out gradually when mouse is removed from the button).
    Thank You once again for your reply.
    Thank You,
    Saurabh Khanna.

  • Fade Music In and Out

    Hi All,
    I have a project I'm working on. The music for the web site
    starts almost immediately. I have a few sections where I'm loading
    other content where I want the music to end. What I would like to
    do is have the ActionScript fade the music out as the player enters
    the frame and the fade the music in as the player enters another
    frame. The name of my music file that is playing is Chill1.
    I'm a noobie so detailed help would be M U C H appreciated!
    Thanks,
    Scott

    Thanks for the reply kglad but I have NO IDEA what the heck
    you are talking about. Like I said I'm new to ActionScript and you
    might as well have written your reply in Russian or Chinese.
    I really need specific code to have any chance of getting
    this to work or a link to a good tutorial site on how to do this.
    The music I want to fade out is playing in Scene1. I have a
    movie clip that when the user enters that movie clip I want the
    sound to fade out and when they exit that movie clip have the sound
    fade in.
    Any help is appreciated!
    Thanks,
    Scott

  • I need an AS2 button that closes out a pop-up window...

    So, I’ve constructed a portfolio site with ActionScript 2.0, but I would like the pop-up window that displays the portfolio image to have its own ‘X’ button that closes the swf movie from the browser.  I’m assuming that the code begins something like this:
    on(release){
    //actionscript 2.0 code that closes the browser window.
    Any suggestions on how this will work across platforms and browsers?
    Best,
    R.

    Hi kglad,
    My main flash as2 file has a stage size of 1200 width x720 height.  I’ve looked online through various methods on creating pop-up browsers that will display a portfolio image when a button on the main.swf is clicked.  Having no luck in finding what I needed (most tutorials just give getURL examples where the image is displayed in a separate tab), it finally dawned on me to create an overlaying movie, of the same size as the document size, on the top layer of the primary flash stage.  Setting the movie symbol as ‘invisible’ keeps the movie symbol inactive and invisible until called by an action.  The button on the main.swf that calls the movie has the following as2 script attached to it:
    on(release){
                   loadMovie("images/aauComp.swf", _root.movie2);
    However, the aauComp.swf file is where the exit button is located.  I need to implement an on(release){} method onto the exit button in aauComp.swf  that will close the movie out in the main.swf file.  Here’s the double wammy, though: the exit button on the called movie file, aauComp.swf, does not recognize any gotoAndStop(); or on(release){} functions relating to itself when it is loaded. For instance, since I could not find any functions that would close the movie out and return me to the main.swf interface, I wrote the following command on the ‘exit’ button in aauComp.swf:
    on(release){
                   _root.gotoAndStop("blank_frame");
    Where “blank_frame” is within a scene of aauComp.swf that is completely empty – which should, in theory, allow for interaction with the main.swf below the loaded movie since there is nothing on that layer of the loaded aauComp.swf movie.  Make sense?  The ‘exit’ button works fine when aauComp.swf is tested and published by itself, but when it is called into the main.swf with the loadMovie(); function, the 'exit' button will not work and, so, it will not forward to the “blank_frame”.
    Any suggestions?  Let me know if you need anything clarified.
    Thanks.

  • How to make movieclip controlled by button fade in/out on mouse over/out?

    Hi,
    I am new to Flash, and have tried searching numerous forums to the answer to this question, but nothing I try seems to work. Basically I am trying to create a single "Image" that triggers different animations when you mouse over different invisible buttons located on specific areas. The technique I am using is basically spacing out the animations over different frames, and using the gotoAndPlay command specifying the where the relevant animation is located.
    Here is the code from my actions layer with two animations:
    stop(); /*This ensures no animations are playing on the first frame*/
    /*Mouse over event for redbutton1*/
    redbutton1.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverToGoToAndPlayFromFrame_2);
    function fl_MouseOverToGoToAndPlayFromFrame_2(event:MouseEvent):void
         gotoAndPlay(2); /*This is the frame where the animaton triggered by redbutton1 is located*/
    /* Mouse Out Event for redbutton1*/
    redbutton1.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);
    function fl_MouseOutHandler_3(event:MouseEvent):void
         gotoAndPlay(1) /*takes animation back to the start of timeline where it stops*/
    /*Mouse over event for bluebutton1*/
    bluebutton1.addEventListener(MouseEvent.MOUSE_OVER, fl_MouseOverToGoToAndPlayFromFrame_2);
    function fl_MouseOverToGoToAndPlayFromFrame_2(event:MouseEvent):void
         gotoAndPlay(30); /*This is the frame where the animaton triggered by bluebutton1 is located*/
    /* Mouse Out Event for bluebutton1*/
    bluebutton1.addEventListener(MouseEvent.MOUSE_OUT, fl_MouseOutHandler_3);
    function fl_MouseOutHandler_3(event:MouseEvent):void
         gotoAndPlay(1) /*takes animation back to the start of timeline where it stops*/
    Now basically all I need is some code that means that instead of abruptly starting and stopping the animation, the animation will fade in/out whenever the mouseover/out events are triggered. Note: the animation doesn't have to finish, it basically only plays while the mouse is over.
    Any help would be greatly appreciated.

    It will help oif you show the code for the code-based tweening.  The basics of getting it working with the MOUSE_OVER/OUR commands is fairly straightforward. 
    You have listeners for both events, and the handlers for each listener is where you activate the tweens.  For more seamless functionality it is usually a good idea to have the starting point of the tween be the point where the object currently is (its x or y (or both) propertiy) instead of a fixed value.

  • My iPhone 5s has stopped playing music out of the speakers. It works when I plug in my headphones but other than that there's no sound. It just randomly happened so I'm not sure if I can fix it or if I need to bring my phone in

    My iPhone 5s has stopped playing music out of the speakers. It works when I plug in my headphones but other than that there's no sound. It just randomly happened so I'm not sure if I can fix it or if I need to bring my phone in. Help?

    Hi Cassilecompte,
    If you are not getting any sound from your iPhone’s speaker, you may want to troubleshoot using the steps in this article -
    iPhone: No sound or distorted sound from speaker
    http://support.apple.com/kb/ts5180
    Thanks for using Apple Support Communities.
    Best,
    Brett L

  • I downloaded new os for my daughter's ipod touch.  I remember during setup after that I checked off my husband's email account and now she is receiving his texts.  How do I fix this.  The "icloud"/ "messages" buttons are both greyed out under settings

    I downloaded new os for my daughter's ipod touch.  I remember during setup after that I checked off my husband's email account and now she is receiving his texts.  How do I fix this.  The "icloud"/ "messages" buttons are both greyed out under settings

    Forgotten RESTRICTIONS Passcode
    - Restore from a backup that was make before you added the Restrictions passcode. If you restore from a backup made with the Restrictions passcode the Restrictions passcode is also restored.
    - Restore to factory settings/new iPod.
    - If you are up to file manipulation see:
    How to reset forgotten Restrictions...: Apple Support Communities

  • Is it possible to create a standard form that can be emailed to anyone and once filled out by the receiver, have a button that the receiver clicks and the form is encrypted and attached an email back to the sender and a preset admin password would open it

    Is it possible to create a standard form that can be emailed to anyone and once filled out by the receiver, have a button that the receiver clicks and the form is encrypted and attached to an email back to the sender and a preset admin password would open it?

    Hello Graphicsguy123,
    You would need to first create the form ( or Widget in EchoSign) first to generate a url which you can paste it in the email being sent to customers. You would need to make sure you have a Document Cloud Enterprise Premium account in order to create a Widget. If you don't have the account, you can use the trial version to test it. Here is the link:
    Global Trial Registration | eSign services from Adobe
    -Rijul

Maybe you are looking for

  • Problem in sending the smartform as an email in a country specific language

    Hi, I am facing a problem in sending a smartform as a email for all other Languages except english and another problem is its sending the email but the output status is still in RED in the messages tab. the program is working fine for english. Please

  • ITunes deleted the music in my iPod

    I have a 3rd generation iPod touch that I've been using for years. I've been plugging my iPod in to my MacBook Air to listen to music as well as charging it for a while now, nothing has ever gone wrong. Until one night, I decided to charge my iPod an

  • How can I get firefox to open a local file on Windows 8.1via File:open?

    I am trying to open a file from the desktop for viewing as a webpage. It is edited in MS Word. When I open the file it just shows the the text of the file, which is html code, it does not run the file as a webpage. How do I get the file to run as a w

  • Installation error code 203 Firefox eBay Companion

    I keep getting installation error 203 when I try to install the Mozilla Firefox eBay companion. Does anybody know how to fix this?

  • How to keep quality of stills in FCP?

    Hi guys I´m a cameraman not an editor and have a few questions for you. I have a project coming up where we will do the whole film as a series of stills. The stills will be shot using a Canon digital SLR camera, then imported to FC Now, is it a way t