| Home | Tutorials | Forums | Articles | Blogs | Movies | Library | Employment | Press | Buy templates |
|
|
#1 |
|
Registered User
Join Date: Jun 2008
Posts: 1
|
I am having issues with a roll over animated button script. The working script was based off an Adobe animated button turotial I found.
This is what the script does. It’s a simple rollover animation. There is a button labeled RedButton_mc. It looks like a button and when you put your mouse on it a small animation happens. When you take your mouse off of it the animation reverses. The top function says to start the first animation (labeled _over) when the mouse is over the button The bottom function says to start the reverse animation (labeled _out) when the mouse leaves the button area. Here is the working script: Code:
RedButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
function buttonOverHandler(MouseEvent) : void {
RedButton_mc.gotoAndPlay("_over");
}
RedButton_mc.addEventListener(MouseEvent.MOUSE_OUT, buttonOutHandler);
function buttonOutHandler(MouseEvent) : void {
RedButton_mc.gotoAndPlay("_out");
}
My problem is that I have more different colored buttons and I am getting errors when I add to this code. All the other buttons have the same names just the Red might say Yellow, or Blue or Green. Here are some of the codes I have tried and the errors I have gotten. The below code are to just get the Blue Button’s “_over” animation to start playing. Below are the 3 ways I have tried to adjust the code to get it working. Any help is appreciated. Code attempt 1: Code:
1 RedButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
2 function buttonOverHandler(MouseEvent) : void {
3 RedButton_mc.gotoAndPlay("_over");
4 }
5
6 RedButton_mc.addEventListener(MouseEvent.MOUSE_OUT, buttonOutHandler);
7 function buttonOutHandler(MouseEvent) : void {
8 RedButton_mc.gotoAndPlay("_out");
9 }
10
11 BlueButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
12 function buttonOverHandler(MouseEvent) : void {
13 BlueButton_mc.gotoAndPlay("_over");
14 }
Duplicate function definition on line 12 Code attempt 2: Code:
1 RedButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
2 function buttonOverHandler(MouseEvent) : void {
3 RedButton_mc.gotoAndPlay("_over");
4 }
5
6 RedButton_mc.addEventListener(MouseEvent.MOUSE_OUT, buttonOutHandler);
7 function buttonOutHandler(MouseEvent) : void {
8 RedButton_mc.gotoAndPlay("_out");
9 }
10
11 BlueButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
12 BlueButton_mc.gotoAndPlay("_over");
Access of undefined property BlueButton_mc. Lines 11 and 12 Code attempt 3: Code:
1 RedButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
2 BlueButton_mc.addEventListener(MouseEvent.MOUSE_OVER, buttonOverHandler);
3 function buttonOverHandler(MouseEvent) : void {
4 RedButton_mc.gotoAndPlay("_over");
5 BlueButton_mc.gotoAndPlay("_over");
6 }
7
8 RedButton_mc.addEventListener(MouseEvent.MOUSE_OUT, buttonOutHandler);
9 function buttonOutHandler(MouseEvent) : void {
10 RedButton_mc.gotoAndPlay("_out");
11 }
Access of undefined property BlueButton_mc. Lines 2 and 5 |
|
|
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| loaded AS2 swf call function in AS3 holder? | mombrun | ActionScript 3.0 | 12 | 12-19-2008 03:56 PM |
| Getting a demo from AS2 to AS3 | flashcooper | ActionScript 3.0 | 4 | 06-13-2008 08:13 PM |
| very odd issue with as2 swf in as3 wrapper, looking for information | nuge32 | ActionScript 3.0 | 0 | 06-10-2008 12:52 AM |
| AS3 Noob here… | basezero | Projectors and CDs | 2 | 04-05-2008 08:25 PM |
| Converting to AS3. How would I do this in AS3 | bubba | ActionScript 3.0 | 7 | 10-08-2007 05:26 PM |