What is the Actionscript code in Flash to make something link on click

Discussion in 'HTML & Website Design' started by Steam, Apr 2, 2009.

  1. #1
    I'm decent with flash no guru or anything but I should be able to figure it out with just a little bit of help. I am having an issue that I can't seem to figure out. It used to be eaier with the older flash versions but I'm using Flash CS4 with Actionscript 3.0 and I have made a movie clip that I would like to be a button and how do I make it so on click it links to somewhere.
     
    Steam, Apr 2, 2009 IP
  2. JREAM

    JREAM Member

    Messages:
    160
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    30
    #2
    on(release) {
    getURL('mysite.html'); // or use something else other than getURL, any other function.
    }
     
    JREAM, Apr 2, 2009 IP
  3. Steam

    Steam Guest

    Messages:
    611
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    1087: Syntax error: extra characters found after end of program. on source on(release) {

    I keep getting this error when I use your code.
     
    Steam, Apr 3, 2009 IP
  4. gluebag

    gluebag Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    getURL is from AS2.0 I do believe. What you want is:

    function gotoGoogle(event:MouseEvent):void{ 
    var googURL:URLRequest = new URLRequest(“http://www.google.com/”); navigateToURL(googURL); 
    } 
    
    linkButton.addEventListener(MouseEvent.CLICK, gotoGoogle);
    Code (markup):
    linkButton being the button, or w/e you want really, but on it's click, it performs that gotoGoogle function, which sets up the URLRequest for google.com.
     
    gluebag, Apr 3, 2009 IP
  5. Steam

    Steam Guest

    Messages:
    611
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #5

    Hey thanks for the help, I'm using Actionscript 3 if that matters? What parts of that do I change out. The goog parts in the code kinda have me confused.
     
    Steam, Apr 3, 2009 IP
  6. jnelson563

    jnelson563 Peon

    Messages:
    72
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    For ActionScript 3.0

    myButton.addEventListener(MouseEvent.CLICK, onMouseClick);

    function onMouseClick(event:MouseEvent):void{

    var request:URLRequest = new URLRequest("link goes here");
    navigateToURL(request,"_blank" );

    }
     
    jnelson563, Apr 3, 2009 IP
  7. Steam

    Steam Guest

    Messages:
    611
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Got it thanks!


    I was adding the action to the layer instead of the actuall button on the layer.
     
    Steam, Apr 13, 2009 IP
  8. Steam

    Steam Guest

    Messages:
    611
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #8
    Nevermind finaly got it!!!!!

    Thanks to the people that helped.
     
    Steam, Apr 13, 2009 IP