Copy link to clipboard
Copied
Hi,
I've made a menu which currently has 2 buttons to go to different frames.
In my actions I have `stop();` on each frame so it doesn't repeatedly loop.
I have added code for 2 buttons which is;
stop();
//click btnTests and go to revision tools
instTest.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5);
function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void
{
gotoAndStop(4);
}
//click btnResources and go to resources
instResources.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndStopAtFrame_5);
function fl_ClickToGoToAndStopAtFrame_5(event:MouseEvent):void
{
gotoAndStop(3);
}
The error I get is 'duplicate function', but I don't know of a way to not have the same function twice.
What do I need to do to have 2 clickable buttons to go to different frames?
Thanks,
Jack
give the function different names (eg, 1.) or use one function and use a conditional statement (eg, 2.):
1.
instTest.addEventListener(MouseEvent.CLICK, f4);
function f4(event:MouseEvent):void
{
gotoAndStop(4);
}
//click btnResources and go to resources
instResources.addEventListener(MouseEvent.CLICK, f3);
function f3(event:MouseEvent):void
{
gotoAndStop(3);
}
2.
instTest.addEventListener(MouseEvent.CLICK, f);
//click btnResources and go to resources
instResources.addEventListener(MouseEvent.CLICK, f);
functi
...Copy link to clipboard
Copied
give the function different names (eg, 1.) or use one function and use a conditional statement (eg, 2.):
1.
instTest.addEventListener(MouseEvent.CLICK, f4);
function f4(event:MouseEvent):void
{
gotoAndStop(4);
}
//click btnResources and go to resources
instResources.addEventListener(MouseEvent.CLICK, f3);
function f3(event:MouseEvent):void
{
gotoAndStop(3);
}
2.
instTest.addEventListener(MouseEvent.CLICK, f);
//click btnResources and go to resources
instResources.addEventListener(MouseEvent.CLICK, f);
function fl(event:MouseEvent):void
{
if(e.currentTarget.name=='instTest'){
gotoAndStop(4);
} else {
gotoAndStop(5);
}
}
Copy link to clipboard
Copied
Thanks kglad - I named them instead of using conditional. I like simple!
Thanks again!
Copy link to clipboard
Copied
you're welcome.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now