Nice.
Here is a sample in which I try to keep things as simple as possible to help you understand.
Basically I add a single click listener to the whole stage. Then I check for the name of the current object instance that is receiving the click event.
This is helpful because:
- We keep things simple without many listeners;
- It helps improve performance;
- We don't have to deal with issues and limitations of targeting object instances inside of tweens;
- And we don't spread our code everywhere.
AS3 code:
import flash.events.MouseEvent;
function changeArea(e:MouseEvent):void
{
if (e.target)
{
if (e.target.name == "houseButton")
gotoAndStop("house");
else if (e.target.name == "shopButton")
gotoAndStop("shop");
else if (e.target.name == "innButton")
gotoAndStop("inn");
else if (e.target.name == "townButton")
gotoAndStop("town");
}
if (e.target.parent)
{
if (e.target.parent.name == "menu")
e.target.parent.play();
}
};
stop();
if (!stage.hasEventListener(MouseEvent.CLICK))
stage.addEventListener(MouseEvent.CLICK, changeArea);
FLA download:
animate_cc_as3_navigation_menu.zip - Google Drive
Please let me know if you don't understand something, if you need to add, fix, or improve anything.
Regards,
JC