19 Replies Latest reply on Jun 4, 2009 12:32 PM by esco1313

    alpha animation

    esco1313

      ok, i'm trying to animate an object's alpha by as...

       

      thats what i thought was corect:

       

      itm3.onRollOver = function() {
          itm3.gotoAndPlay("over");
      }
      itm3.onRollOut = function() {
          itm3.gotoAndPlay("out");
      }
      itm3.onPress = function() {
      var newsFade:Tween = new Tween (_root.newsMc,alpha,Regular.easeIn,100,1,2,true);

      }

       

      not working...

        • 1. Re: alpha animation
          esco1313 Level 1

          ok got the right code. but doesnt work...

           

          var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

          • 2. Re: alpha animation
            kglad Adobe Community Professional & MVP

            use trace(newMc) to see if you have the correct path/instance name.  (in your first message you were using _root.newMc)

            • 3. Re: alpha animation
              esco1313 Level 1

              yeah its at level 0. so either way, it should work...

               

              something weird is happening:

               

              when i write this code:

               

              itm3.onPress = function() {

              var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

              }

               

              nothing happens. when i write THIS code:

               

              itm3.onPress = function() {

              var newsfade:Object = new Tween(newsMc, "_x", Strong.easeOut, 100, 0, 1, true);

              }

               

              it moves.(works)

               

              and when i write THIS code:

               

              itm3.onPress = function() {

              var newsfade:Object = new Tween(menuMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

              }

               

              itm3 is a mc (works as button) inside the menuMc. when i click, the button doesnt fade out like it would suppose to...only the "hightlight" i created (on over) in my itm3 fades out...???

              • 4. Re: alpha animation
                kglad Adobe Community Professional & MVP

                 

                when i write this code:

                 

                itm3.onPress = function() {

                var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);

                }

                 

                nothing happens. when i write THIS code:

                 

                itm3.onPress = function() {

                var newsfade:Object = new Tween(newsMc, "_x", Strong.easeOut, 100, 0, 1, true);

                }

                 

                it moves.(works)

                 


                 

                 

                i don't think that's possible (double check for typos and don't change timeline frames).  if you're sure you're correct, create a test fla that demonstrates your assertion and post a link.

                • 5. Re: alpha animation
                  esco1313 Level 1

                  actually, i'll attach here my scene. I think that, if you say my code is correct, it might be something else going on...

                  • 6. Re: alpha animation
                    kglad Adobe Community Professional & MVP

                    you need to embed your font.

                    • 7. Re: alpha animation
                      esco1313 Level 1

                      ahhhh!!! ok stupid question...

                       

                      embed my font = new font in the library?...

                      • 8. Re: alpha animation
                        kglad Adobe Community Professional & MVP

                        in newMc.  you can't fade text unless it's embedded.  that's the problem.  newsMc was fading but you didn't see it because you failed to embed the font in newsMc.

                        • 9. Re: alpha animation
                          esco1313 Level 1

                          perfect!

                           

                          works! thanks a lot, again.

                           

                          one last thing. i want it that, when the newsMc's alpha reaches 0, that this mc (newsMc) gets removed. is it the proper way to do it? because when it fades out, it still is clickable.

                           

                          i tried:

                           

                          itm3.onPress = function() {

                           

                          var newsfade:Object = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                              var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
                              var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
                              var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
                          }

                           

                          if (newsMc._alpha = 0) {
                              this.removeMovieClip();
                          }

                          • 10. Re: alpha animation
                            kglad Adobe Community Professional & MVP

                            yes.

                             

                            the tween class has an onMotionFinished method you can use.  but you'll want to NOT make your tween local to a function:

                             

                            var newsfade:Tween;

                             

                            itm3.onPress = function() {

                             

                            newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                                var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
                                var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
                                var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
                            }

                             

                            newsfade.onMotionFinished=function(){

                            newsMc.removeMovieClip();

                            }

                            • 11. Re: alpha animation
                              esco1313 Level 1

                              ok i changed it to what you wrote. i understand what you are saying. its not working though... weird because its pretty logic...

                               

                              var newsfade:Tween;
                              itm3.onPress = function() {

                              newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                                  var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
                                  var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
                                  var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
                              }
                              newsfade.onMotionFinished=function(){
                              newsMc.removeMovieClip();
                              }

                              • 12. Re: alpha animation
                                kglad Adobe Community Professional & MVP

                                is newsMc at a removabe depth (between 0 and 2**20)?

                                 

                                use newsMc.getDepth() to check and use newsMc.swapDepths() to move it to a removeable depth.

                                • 13. Re: alpha animation
                                  esco1313 Level 1

                                  this.attachMovie('newsMcId', 'newsMc', 1, {_x:590, _y:118});

                                   

                                  means its on depth1 no?


                                  what does 2**20 mean?

                                  • 14. Re: alpha animation
                                    kglad Adobe Community Professional & MVP

                                    2**20 means 2 to the 20th power.

                                     

                                    you're correct, newsMc is created at a removeable depth.  the problem is we can't define a tween instance method until the tween instance exists.  use:

                                     

                                    var newsfade:Tween = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                                    newsfade.stop();
                                    itm3.onPress = function() {
                                        newsfade.start();
                                        newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                                        var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
                                        var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
                                        var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
                                       
                                    }
                                    newsfade.onMotionFinished = function(){
                                        newsMc.removeMovieClip();
                                    }

                                    • 15. Re: alpha animation
                                      esco1313 Level 1

                                      perfect! works fine! thanks a lot.

                                       

                                      btw, i removed a line in your code still works...

                                       

                                      var newsfade:Tween = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                                      newsfade.stop();
                                      itm3.onPress = function() {
                                          newsfade.start();
                                         // newsfade = new Tween(newsMc, "_alpha", Strong.easeOut, 100, 0, 1, true);
                                          var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,375,150,.75,true);
                                          var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,375,150,.75,true);
                                          var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,375,150,.75,true);
                                         
                                      }
                                      newsfade.onMotionFinished = function(){
                                          newsMc.removeMovieClip();
                                      }

                                      • 16. Re: alpha animation
                                        esco1313 Level 1

                                        i have another question regarding all this...

                                         

                                        i dont think i'm using the proper way to do this but...

                                         

                                        i'm removing the clip because i'm leaving the section. That means that each time i come back in this section, i'll have to attach movieclip?

                                        and for the other sections as well?

                                         

                                        ex:

                                         

                                        itm3.onPress = function() {
                                            itm3.enabled = false;
                                            itm3.gotoAndStop("inside");
                                            itm1.enabled = true;
                                            itm1.gotoAndStop("up");
                                            itm2.enabled = true;
                                            itm2.gotoAndStop("up");
                                            itm4.enabled = true;
                                            itm4.gotoAndStop("up");
                                            itm5.enabled = true;
                                            itm5.gotoAndStop("up");
                                            newsfadeOut.start();
                                            var menuTween:Tween = new Tween (menuMc,"_x",Regular.easeInOut,menuMc._x,150,.75,true);
                                            var contentsTween:Tween = new Tween (contentsMc,"_x",Regular.easeInOut,contentsMc._x,150,.75,true);
                                            var contactMainMcTween:Tween = new Tween (contactMainMc,"_x",Regular.easeInOut,contactMainMc._x,150,.75,true);
                                            newsfadeOut.onMotionFinished=function(){
                                                newsMc.removeMovieClip();
                                                _root.attachMovie('screenId', 'screen', 13, {_x:375, _y:130});
                                                screen.onLoad = function() {
                                                screenfadeIn.start();
                                                }
                                               
                                            }
                                        }

                                        • 17. Re: alpha animation
                                          kglad Adobe Community Professional & MVP

                                          for a movieclip that do not want to be visible and do not want to respond to the mouse you can use:

                                           

                                          newsMc._visible = false;

                                           

                                          for a movieclip that you want to be visible and not respond to the mouse, you can use:

                                           

                                          newsMc.enabled = false;

                                          1 person found this helpful
                                          • 18. Re: alpha animation
                                            esco1313 Level 1

                                            thx!

                                            • 19. Re: alpha animation
                                              kglad Adobe Community Professional & MVP

                                              you're welcome.