Skip to main content
Known Participant
September 4, 2010
Answered

Simple actionscript question

  • September 4, 2010
  • 1 reply
  • 612 views

I have a project I'm working on and I'm new to actionscript 3.  Below is the code that i have on frame 1 and it works fine for one button.

import flash.events.MouseEvent;
stop();

//--- Buttons

buy_btn.addEventListener(MouseEvent.MOUSE_OVER, buyROLL);
buy_btn.addEventListener(MouseEvent.MOUSE_OUT, buyOUT);

function buyROLL(event:MouseEvent):void {
buy_mov.gotoAndPlay(2);
}
function buyOUT(event:MouseEvent):void {
buy_mov.gotoAndPlay(15);
}

When I try to add multiple buttons like the code below, flash freaks out!  It doesn't even stop on the first frame.  It plays the movie straight through.  I get these errors "Scene 1, Layer 'Layer 2', Frame 1, Line 20 1120: Access of undefined property about_mov." and "Scene 1, Layer 'Layer 2', Frame 1, Line 23 1120: Access of undefined property about_mov."

import flash.events.MouseEvent;
stop();

//--- Buttons

buy_btn.addEventListener(MouseEvent.MOUSE_OVER, buyROLL);
buy_btn.addEventListener(MouseEvent.MOUSE_OUT, buyOUT);

about_btn.addEventListener(MouseEvent.MOUSE_OVER, aboutROLL);
about_btn.addEventListener(MouseEvent.MOUSE_OUT, aboutOUT);

function aboutROLL(event:MouseEvent):void {
about_mov.gotoAndPlay(2);
}
function aboutOUT(event:MouseEvent):void {
about_mov.gotoAndPlay(15);
}

Am I doing this right??? Is there an easier, more efficient way to do this?

This topic has been closed for replies.
Correct answer Ned Murphy

Chances are you do not have an instance name assigned to the about_mov movieclip.  When there is a coding error in an AS3 file, the erratic behavior you see is normal.

1 reply

Ned Murphy
Ned MurphyCorrect answer
Legend
September 4, 2010

Chances are you do not have an instance name assigned to the about_mov movieclip.  When there is a coding error in an AS3 file, the erratic behavior you see is normal.

Ger75Author
Known Participant
September 5, 2010

Thank you, thought I checked everything, but it turns out i had one of the mc's n

ames wrong. Thanks

Ned Murphy
Legend
September 5, 2010

You're welcome