animated button

This is a discussion on animated button within the Macromedia Flash forums in Adobe Tools category; I'm trying to create an animated rollover for a linked image. Basically, I have 2 images (equal in size), and I want to fade from one to the other on mouse over. I've created a movie clip that houses this crossfade, and placed it in the second keyframe of a button, but it doesn't work. I've got the first image in the "off" frame, the animation in the "on" frame, nothing in the "down" or "hit" frames. Any ideas? Thanks....

Go Back   Application Development Forum > Adobe Tools > Macromedia Flash

Object Mix

Register FAQ Calendar Search Today's Posts Mark Forums Read
  #1  
Old 05-17-2008, 04:24 PM
mightypants
Guest
 
Default animated button

I'm trying to create an animated rollover for a linked image. Basically, I
have 2 images (equal in size), and I want to fade from one to the other on
mouse over. I've created a movie clip that houses this crossfade, and placed
it in the second keyframe of a button, but it doesn't work. I've got the first
image in the "off" frame, the animation in the "on" frame, nothing in the
"down" or "hit" frames.

Any ideas? Thanks.

Reply With Quote
  #2  
Old 05-17-2008, 06:46 PM
NedWebs
Guest
 
Default Re: animated button

Does it do anything when you hover it? Is the file small enough to make it available for a look see?
Reply With Quote
  #3  
Old 05-17-2008, 07:35 PM
mightypants
Guest
 
Default Re: animated button

I didn't have the original image and the animated one lined up quite right, so
when I hovered over it the image shifted slightly to the new location, but the
animation itself didn't occur.

The file is pretty big.

Reply With Quote
  #4  
Old 05-17-2008, 07:39 PM
clbeech
Guest
 
Default Re: animated button

you don't really need to place the MC within a button and can apply the
handlers to the MC itself. in the MC create a new layer called actions - place
a stop() on the first frame of the actions layer - move out to the end of the
animation and insert a new keyframe on the actions layer - place another stop
there. now apply handlers to the MC from the main timeline:

my_btn.onRollOver = function() {
this.gotoAndPlay(2);
}

my_btn.onRollOut = function() {
this.gotoAndStop(1);
}

Reply With Quote
  #5  
Old 05-17-2008, 07:44 PM
NedWebs
Guest
 
Default Re: animated button

What version of Actionscript are you using? clbeech's approach is a good one, but if you're using AS3 the code will differ a bit.
Reply With Quote
  #6  
Old 05-17-2008, 10:09 PM
mightypants
Guest
 
Default Re: animated button

I'm using AS 3.0. Thanks.
Reply With Quote
  #7  
Old 05-17-2008, 11:56 PM
clbeech
Guest
 
Default Re: animated button

good point Ned - if you are using 3 then the code would be as follows:


function rollover() {
mcBtn.gotoAndPlay(2);
}

function rollout() {
mcBtn.gotoAndStop(1);
}

mcBtn.addEventListener(MouseEvent.ROLL_OVER, rollover);
mcBtn.addEventListener(MouseEvent.ROLL_OUT, rollout);

Reply With Quote
  #8  
Old 05-19-2008, 12:30 AM
mightypants
Guest
 
Default Re: animated button

okay...so I added the stop frames, as far as adding the handler...do I add that
action to the first frame of the movie clip in the main timeline? I tried
copying the script you wrote that and got these error messages when I tried to
preview:


1120: Access of undefined property mcBtn.

Reply With Quote
  #9  
Old 05-19-2008, 09:48 AM
clbeech
Guest
 
Default Re: animated button

yes add the script(s) to the first frame - usually on a new layer called
actions. the name 'mcBtn' is an example of an 'instance name' of your button -
you need to change it to the one you have assigned. If you have not given the
buttons instance names - do so by selecting the button and looking in the
properties panel and typing a name in the box provided on the left side of the
panel.

Reply With Quote
  #10  
Old 05-19-2008, 10:33 AM
mightypants
Guest
 
Default Re: animated button

I had the instance name thing taken care of. I just moved the action script to a new layer, but got the same result.
Reply With Quote
Reply


Thread Tools
Display Modes


All times are GMT -5. The time now is 12:13 AM.


Powered by vBulletin® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
vB Ad Management by =RedTyger=

In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.