7 Replies Latest reply on Jan 20, 2012 8:27 AM by kglad

    Adding animation code question

    LuisRM Level 1

      I'm trying to add animation code to a layer that has a clickthrough tag on it. I feel like I'm close, but am missing something. Here is what I have so far and I've linked a basic CS4 .fla file that may better illustrate my issue.

       

       

      var loop = 0;
      
      clickTAG_btn.onRelease=function(){
      getURL(clickTag,"_blank");
      }
      
      mc_complexButton.onRollOver=function(){
      this._parent.play(1);
      }
      
      mc_complexButton.onRollOut=function(){
      this._parent.gotoAndStop(10);
      }
      

       

      My clickTAG coding is correct. But I'm trying to have the mc_complexButton rotate when you roll over the clickTAG button. It doesn't work unless I hide the layer that has the clickTAG button. I'm pretty sure that I'm not referencing the mc_complexButton correctly, or sure what numbers need to be in the brackets after it. Thanks for any help or explanation.

       

      http://dl.dropbox.com/u/24097164/Valentine_testheart.fla

       

      Just for reference, I'm going to add the animation to the heart in the final version, the circle is just a placeholder to get the code correct.

        • 1. Re: Adding animation code question
          kglad Adobe Community Professional & MVP

          mc_complexButton is the correct reference (if that rollover and rollout are triggered by the object you want to rotate).  i don't see any code to rotate that button, though.

          • 2. Re: Adding animation code question
            LuisRM Level 1

            The code is in the actual expanding button (mc_complexButton). It's a classic tween from frame 1 to 15. Here is what's in there.

             

            Frame 1 of mc_complexButton

            stop(); // stop the movie clip from playing (stop button from growing, we want that when the mouse rolls over only
            
            this.onEnterFrame = function(){
                if(rewind == true){   //if rewind switch is set to true play backwards
                    prevFrame();        // play backwards
                }
            }
            
            this.onRollOver = function(){
                rewind = false; //set variable (or switch) that decides wether ot not to play backwards...
                play();    // play this movie clip.. (grow the button(tween));
            }
            
            this.onRollOut = function(){
                rewind = true;    //set or rewind switch to true so it will play backwards...
            }
            
            this.onRelease = function(){
                getURL("http://www.anysite.com","_blank");
            }
            

             

            Frame 15 of mc_complexButton

             

            stop();
            

             

             

            Hope that helps in figuring out the issue. Thanks again!

            • 3. Re: Adding animation code question
              kglad Adobe Community Professional & MVP

              that's really bad coding especially for a banner ad.

               

              remove all that coding on the buttons timeline except the two stop() lines of code on the first frame and last frame.

               

              the only code should be:

               

               

              var loop = 0;
              
              clickTAG_btn.onRelease=function(){
              getURL(clickTag,"_blank");
              }

              clickTAG_btn.onRollOver=mc_complexButton.play();
              clickTAG_btn.onRollOut=reverseF;

              mc_complexButton.onRollOver=function(){ this._parent.play(1);
              this.play();
              } mc_complexButton.onRollOut=function(){ this._parent.gotoAndStop(10);
              reverseF();
              }
              function reverseF(){
              mc_complexButton.onEnterFrame=function(){
              this.prevFrame();
              if(this._currentFrame==1){
              delete this.onEnterFrame;
              }
              }

              }
              1 person found this helpful
              • 4. Re: Adding animation code question
                LuisRM Level 1

                Thanks a lot for taking the time to write up this code. I really appreciate it. I tried the code as it was and the button didn't expand on rollover. I made a couple of tweaks with the TAG letters (button name is clickTag_btn and the instance name is clickTag_btn).

                 

                I removed the code from the actual expanding button. Frame 1 and 15 only have stop();

                 

                The actual clickthrough box (clickTag_btn) on the top layer has no code.

                 

                Here is what I have on the Actions layer in Frame 1.

                 

                 

                var loop = 0;
                
                clickTag_btn.onRelease=function(){
                getURL(clickTAG,"_blank");
                }
                
                clickTag_btn.onRollOver=mc_complexButton.play();
                clickTag_btn.onRollOut=reverseF;
                
                mc_complexButton.onRollOver=function(){
                this._parent.play(1);
                this.play();
                 }
                
                mc_complexButton.onRollOut=function(){
                this._parent.gotoAndStop(10);
                reverseF();
                 }
                function reverseF(){
                
                mc_complexButton.onEnterFrame=function(){
                this.prevFrame();
                if(this._currentFrame==1){
                delete this.onEnterFrame;
                }
                }
                
                
                
                }
                

                 

                It's still not working like that now though. Did I miss something with your previous code being indented in a second box? If I remove the top layer though, the button does expand, so it has something to do with the complex button not reacting to that top layer. Thanks for your time.

                 

                I also just noticed that if I click into the expanding graphic Mc_complexButton, it is a graphic with an instance name of gr_circle. I don't know if that makes a difference or not.

                • 5. Re: Adding animation code question
                  kglad Adobe Community Professional & MVP

                  use:

                   

                   

                   

                   

                  var loop = 0;
                  
                  clickTag_btn.onRelease=function(){
                  getURL(clickTAG,"_blank");
                  }
                  
                  clickTag_btn.onRollOver=function(){
                  mc_complexButton.play();
                  }
                  clickTag_btn.onRollOut=reverseF; mc_complexButton.onRollOver=function(){ this._parent.play(1); this.play(); } mc_complexButton.onRollOut=function(){ this._parent.gotoAndStop(10); reverseF(); } function reverseF(){ mc_complexButton.onEnterFrame=function(){ this.prevFrame(); if(this._currentFrame==1){ delete this.onEnterFrame; } } }
                  • 6. Re: Adding animation code question
                    LuisRM Level 1

                    Thanks for your help. I dug around a bit and noticed that I didn't have the button named as mc_complexButton in the Properties panel. It said it was an Instance of it, but it was blank in the Properties name box. I added the name and it worked like a charm. I'm now going to take this code, take a good look at it and determine how and why it works so I can apply it to other things. Thanks again for your help, you are a real quality contributor to these forums!

                    • 7. Re: Adding animation code question
                      kglad Adobe Community Professional & MVP

                      you're welcome.