A Flash Developer Resource Site

Results 1 to 11 of 11

Thread: How to make button load a webpage?

  1. #1
    Junior Member
    Join Date
    Jun 2008
    Posts
    2

    How to make button load a webpage?

    Hi, I'm really new to Flash CS3 and ActionScript 3, and need to make an online portfolio. How do I use ActionScript to make a button load a webpage?

    Thanks!

  2. #2
    Member
    Join Date
    Jun 2007
    Posts
    47
    function gotoAdobeSite(event:MouseEvent):void
    {
    var adobeURL:URLRequest = new URLRequest("http://www.adobe.com/");
    navigateToURL(adobeURL);
    }

    linkButton.addEventListener(MouseEvent.CLICK, gotoAdobeSite);

  3. #3
    Junior Member
    Join Date
    Jun 2008
    Posts
    2
    Thanks!

  4. #4
    Member
    Join Date
    Jun 2007
    Posts
    47

    Talking

    No Problem.

  5. #5
    Junior Member
    Join Date
    Jun 2008
    Posts
    8
    if i'm using a flash navigation menu and want it to open in the same window how do i do that cos atm when clicking on a button it opens in a new window.

    home_btn.addEventListener(MouseEvent.CLICK,clickHa ndler1);
    browse_btn.addEventListener(MouseEvent.CLICK,click Handler2);

    function clickHandler1(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://xxxxxxxxxx.com/"));
    }
    function clickHandler2(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://xxxxxxxxxx.com/browse.php"));
    }

  6. #6
    Member
    Join Date
    Jun 2007
    Posts
    47
    Add _self to the end of the urlRequest like I did here.

    Code:
    function clickHandler1(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://xxxxxxxxxx.com/"), "_self");
    }
    function clickHandler2(event:MouseEvent):void{
    navigateToURL(new URLRequest("http://xxxxxxxxxx.com/browse.php"), "_self";
    }

  7. #7
    Junior Member
    Join Date
    Jun 2008
    Posts
    8
    i get an error then.

    1084: Syntax error: expecting rightparen before rightbrace.

  8. #8
    Member
    Join Date
    Jun 2007
    Posts
    47
    sorry I forgot to add the other brace
    Code:
    function (event:MouseEvent):void{
    navigateToURL(new URLRequest("http://xxxxxxxxxx.com/browse.php"), "_self");
    }

  9. #9
    Junior Member
    Join Date
    Jun 2008
    Posts
    8
    i have no errors now but it is still the same before, it opens a new tab/window.

  10. #10
    Junior Member
    Join Date
    Jun 2008
    Posts
    8
    sorry askurat my bad it worked perfect lol.. i messed up.

    thanx for your help.

  11. #11
    Member
    Join Date
    Jun 2007
    Posts
    47
    no problem. I had another possible solution but I lost my internet connection last night.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center