| Register | FAQ | Calendar | Search | Today's Posts | Mark Forums Read |
|
#1
| |||
| |||
| 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. |
|
#2
| |||
| |||
| Does it do anything when you hover it? Is the file small enough to make it available for a look see? |
|
#3
| |||
| |||
| 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. |
|
#4
| |||
| |||
| 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); } |
|
#5
| |||
| |||
| 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. |
|
#6
| |||
| |||
| I'm using AS 3.0. Thanks. |
|
#7
| |||
| |||
| 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); |
|
#8
| |||
| |||
| 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. |
|
#9
| |||
| |||
| 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. |
|
#10
| |||
| |||
| I had the instance name thing taken care of. I just moved the action script to a new layer, but got the same result. |
![]() |
| Thread Tools | |
| Display Modes | |
In an effort to better serve ads to our visitors, cookies are used on objectmix.com. For more information, check out our Privacy Policy.