Copy link to clipboard
Copied
I have a basic web site in flash with each "page" on a separate keyframe in the timeline.
On my links page, I have buttons that should open urls in a new window...when I try to add the script to the buttons and publish, it cycles through all my pages in a constant loop.
This is what I have tried to do that is not working (adding link to only one of the buttons):
stop();
Links_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);
function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void
{
gotoAndPlay(5);
}
stop();
this.facebook_link.addEventListener("click", fl_ClickToGoToWebPage_5);
function fl_ClickToGoToWebPage_5() {
window.open("http://www.facebook.com/liebekunstart", "_blank");
}
Try using the navigateToURL() function instead of a javascript cvommand for that second button function. You should also keep things consistent and follow the coding of the first button... it is properly coded.
facebook_link.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5);
function fl_ClickToGoToWebPage_5(event:MouseEvent) {
navigateToURL(new URLRequest("http://www.facebook.com/liebekunstart"), "_blank");
}
Note: stop(); is a timeline command, so you only need one per any frame in
...Copy link to clipboard
Copied
If it helps I uploaded my .fla here:
Copy link to clipboard
Copied
Try using the navigateToURL() function instead of a javascript cvommand for that second button function. You should also keep things consistent and follow the coding of the first button... it is properly coded.
facebook_link.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5);
function fl_ClickToGoToWebPage_5(event:MouseEvent) {
navigateToURL(new URLRequest("http://www.facebook.com/liebekunstart"), "_blank");
}
Note: stop(); is a timeline command, so you only need one per any frame in which you wish to stop.
Copy link to clipboard
Copied
Thank you! I still run into a problem however...I tried to add another button link for the same page...? I tried and get the same problem...here is what I did:
stop();
Links_btn.addEventListener(MouseEvent.CLICK, fl_ClickToGoToAndPlayFromFrame_5);
function fl_ClickToGoToAndPlayFromFrame_5(event:MouseEvent):void
{
gotoAndPlay(5);
}
facebook_link.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5);
function fl_ClickToGoToWebPage_5(event:MouseEvent)
{
navigateToURL(new URLRequest("http://www.facebook.com/liebekunstart"), "_blank");
}
bts_link.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5);
function fl_ClickToGoToWebPage_5(event:MouseEvent)
{
navigateToURL(new URLRequest("http://www.btscampaign.org"), "_blank");
}
Copy link to clipboard
Copied
I figured it out by accident...adding a different number to the event worked fl_ClickToGoToWebPage_6...hope that is a correct fix
Copy link to clipboard
Copied
Yes, that is a valid fix. You cannot have the same name for different functions. Just to clarify, you changed the name of the event handler function, not the event.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more