Skip to main content
Known Participant
January 19, 2012
Answered

Adding animation code question

  • January 19, 2012
  • 2 replies
  • 999 views

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.

This topic has been closed for replies.
Correct answer kglad

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; } } }

2 replies

kglad
Community Expert
Community Expert
January 19, 2012

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;
}
}

}
LuisRMAuthor
Known Participant
January 19, 2012

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.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
January 19, 2012

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; } } }
kglad
Community Expert
Community Expert
January 19, 2012

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.

LuisRMAuthor
Known Participant
January 19, 2012

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!