3 Replies Latest reply on Aug 14, 2010 4:37 AM by Ned Murphy

    Flash button - linking


      Hey, Firstly Im a total noob to flash. I created a button but cant link it a URL. The button does an action and makes a sound when the mouse cursor is over it and then does the same action but in the opposite direction when the cursor is taken off and the button returns to its original state. However when I add:                                                                                                                                                                                                                         on(release)
      getURL("http://www.google.co.uk", "_blank");
      to get the button to go to a URL it just plays the action and sound over in a continuous loop. The code I have for the button to get it to do what I want is:                                                                                                                                                                                                               // Btn2 Over function
      function btn2Over(event:MouseEvent):void {
      btn2.gotoAndPlay("over"); // go into btn2 movieclip and play the over frame label
      // Btn2 Out function
      function btn2Out(event:MouseEvent):void {
      btn2.gotoAndPlay("out");     // go into btn2 movieclip and play the out frame label
      // Btn2 Down function
      function btn2Down(event:MouseEvent):void {
      //this.gotoAndPlay("myLabel"); // play any frame label in any movieclip

      // Btn2 listeners
      btn2.addEventListener(MouseEvent.ROLL_OVER, btn2Over);
      btn2.addEventListener(MouseEvent.ROLL_OUT, btn2Out);
      btn2.addEventListener(MouseEvent.CLICK, btn2Down);
      ////////////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////
      //                                                                                                                                                                                                                         Any help would be greatly appreciated, I believe it is the line //this.gotoAndPlay("myLabel"); // play any frame label in any movieclip. that is incorrect as I modified this code from a button that I found online that did simliar actions to mine. Thanks Ash

        • 1. Re: Flash button - linking
          Ned Murphy Adobe Community Professional & MVP

          The problem is you are mixing two different versions of actionscript, which will not work in the same file.  Get rid of all the on(release)... code, which is AS2, and stick with the AS3 code, making sure that your publish settings are set for AS3.


          Then change your btn2Down code to be...


          function btn2Down(event:MouseEvent):void {
               navigateToURL(new URLRequest("http://www.google.co.uk"));



          If you don't intend to use the gotoAndPlay line, then just remove it from that function, but it is not the problem

          • 2. Re: Flash button - linking
            Ash_2788 Level 1

            Thank you! that worked perfectly, just one last question; how do I get it to open the link in the same window rather than it opening a new one each time?


            Also I want the button to link to a dreamweaver page rather than a webpage.


            Thanks in advance, Ash

            • 3. Re: Flash button - linking
              Ned Murphy Adobe Community Professional & MVP

              If you look up the navigateToURL function in the help documentation, all of the window options are specified.  To open in the same window use...


              function btn2Down(event:MouseEvent):void {
                   navigateToURL(new URLRequest("http://www.google.co.uk"), "_self" );



              As far as I know a Dreamweaver page is a web page so I do not understand your other question except to say that you should specify the name of the file in the URLRequest