It was at this point that my lack of programming experience began to catch up with me...
Button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);
function fl_MouseClickHandler_3(event:MouseEvent):void
{
Green.x += 30;
}
Button_2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_4);
function fl_MouseClickHandler_4(event:MouseEvent):void
{
Green.x -= 30;
}
Yellow.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);
function fl_MouseClickHandler_3(event:MouseEvent):void
{
Green.y += 30;
}
Yellow.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_4);
function fl_MouseClickHandler_4(event:MouseEvent):void
{
Green.y -= 30;
}
After running the program I got this error:
Scene 1, Layer 'Actions', Frame 1, Line 24 1021: Duplicate function definition.
When I copied the event listeners I forgot to change the function name for the event handlers, so they were duplicated, which caused this error. Also, the red and blue buttons are labelled "Button_1" and "Button_2". I soon changed the names so that I wouldn't have to remember what color goes with which function.
Also, the names of the event listener targets for the yellow and orange buttons were duplicated, which resulted in both buttons being put out of commission.There was no resulting error message; both the yellow and orange buttons simply failed to function.
This is the code that worked:
button_1.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_3);
function fl_MouseClickHandler_3(event:MouseEvent):void
{
Green.x += 30;
}
button_2.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_4);
function fl_MouseClickHandler_4(event:MouseEvent):void
{
Green.x -= 30;
}
Yellow.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_1);
function fl_MouseClickHandler_1(event:MouseEvent):void
{
Green.y += 30;
}
Orange.addEventListener(MouseEvent.CLICK, fl_MouseClickHandler_2);
function fl_MouseClickHandler_2(event:MouseEvent):void
{
Green.y -= 30;
}