Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Question on ActionScript 3 for basic web site...

New Here ,
Jan 04, 2014 Jan 04, 2014

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");

}

TOPICS
ActionScript
704
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Jan 04, 2014 Jan 04, 2014

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

...
Translate
New Here ,
Jan 04, 2014 Jan 04, 2014

If it helps I uploaded my .fla here:

http://www.liebekunst.com/index2test.fla

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 04, 2014 Jan 04, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2014 Jan 04, 2014

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");

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jan 04, 2014 Jan 04, 2014

I figured it out by accident...adding a different number to the event worked fl_ClickToGoToWebPage_6...hope that is a correct fix

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jan 05, 2014 Jan 05, 2014
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines