4 Replies Latest reply on Nov 6, 2010 3:34 PM by janineabc

    Background Fades in and out!?!

    janineabc Level 1

      Hi,

       

      In need of a little actionscript help!

       

      Im creating a microsite, in which the background colour changes depending on which section you are in!

       

      I want it so that when i go on one section the current background fades out as the new on faids in!

       

      Ive got the fades in's sorted, however is there some sort of script that i can put in that tells the current background to faid out??

       

       

      Also say im in the red section and then want to load a diffrent aspect of the red section! I dont want it to re-load the Red background! Is there some way of achieving that?? My first throught was to use some sort of IF statment, however im not exactly sure how i do this?

       

      I would appreciate any help to achieve this as i'm still learning! 

       

      thankyou!

        • 1. Re: Background Fades in and out!?!
          Ned Murphy Adobe Community Professional & MVP

          How do you curently manage the fade-in"s?

          • 2. Re: Background Fades in and out!?!
            janineabc Level 1

            Via Motion tween!

             

            Probably not the best way tho.

            • 3. Re: Background Fades in and out!?!
              Ned Murphy Adobe Community Professional & MVP

              Seeing as how you're in an actionscript forum, the proper recommendation will be to tell you to work things out using actionscript tweens instead of timeline tweens.

               

              Here's an example that you can plug in to a new empty file and try.  Just create a Movieclip and give it an instance name of 'mc'.  Then place this code in the timeline in the same frame (different layer)...

               

               

              import mx.transitions.Tween;
              import mx.transitions.easing.Regular;

               

              var tweenToAlpha;
              var tw:Tween;

               

              mc.onRelease = function(){
                  if(mc._alpha > 50){
                      tweenToAlpha = 10;  // fade out to 10% alpha
                  } else {
                      tweenToAlpha = 100; // fade in to 100% alpha
                  }
                  tw = new Tween(mc, "_alpha", Regular.easeIn, mc._alpha, tweenToAlpha, 1, true);
              }

               

               

              The workings are basically... when you click the mc, if its alpha is > 50%, fade it out, otherwise fade it in.  I only have it fade to 10% so you can still see the mc to click it, though you could still click it if it went to 0.

               

              I recommend you play with it a bit and study it until you understand what it is doing.  Then you'll stand a better chance of incorporating it into your design... it will free you from using the timeline for tweening.  Look up the Tween class to understand the arguments that are used in the Tween constructor.

              • 4. Re: Background Fades in and out!?!
                janineabc Level 1

                Thankyou!

                 

                Will give it a try and get back to you at some point tomorrow!