11 Replies Latest reply on Oct 30, 2007 9:40 PM by robrob1953

    Button link to html

    awdgsxdude
      I used to use flash quite a bit years ago (flash 4-5) and now it is so different. I have tried looking in books and online for the answer with no luck.
      Real simple, I just want a button to, when pressed, link to an html source. I have tried everything, including just copy/pasting from what other people have posted. Perhaps you can take a look at my work and see where I went wrong?
      http://www.mediafire.com/?8gj112yxjdb

      Thank you so much for any help you can suggest!
        • 1. Re: Button link to html
          clbeech Level 3
          The file you have uploaded here is a swf, we would need the fla to look at the code. if you are using AS2, the call would be getURL(), and for a button look something like this:

          my_btn.onPress = function() {
          getURL( ' http://www.thedomain.com' , '_self');
          }

          this code would be placed on the main timeline and there should be a button on the stage with the instance name 'my_btn', change that to reflect the instance name of your button(s).
          • 2. Re: Button link to html
            awdgsxdude Level 1
            Sorry, I uploaded the swf instead of the zip. Here it is ..
            http://www.mediafire.com/?8wwsl9gdwce

            I followed your instruction, but it still does not work. Perhaps I did not create the button correctly. Are you able to see what my error is?
            • 3. Re: Button link to html
              balamurugan@flipdesign.in
              I saw the zip file but the point is you has not specify the parameter within single quote like ' http://www.domainName' you need to specify within single quote and it will work i tested specifying in your file it is working...
              if you want to specify for the button you can follow the clbeech code it is perfect
              in that case don't forgot to name the button
              • 4. Re: Button link to html
                awdgsxdude Level 1
                I see what you are saying, and I even just copy/paste what clbeech posted, and yet it still does not work. I have reuploaded my work with what I would think should work based off of what you are saying. I do not get any errors when I publish it, yet no web url will load or attempt to load.
                http://www.mediafire.com/?62djnct0xd1

                Thank you both so much for trying to help out, I appreciate it.
                • 5. Re: Button link to html
                  clbeech Level 3
                  no prob. unfortunately, you must be using CS3, I'm afraid I can't view the file unless you can publish down to Flash8. bala' has the right idea though and has seen and tested your file, perahps you did not give the button an instance name, or change the code above to reflect that name.

                  Also, if you are using CS3, it will publish to AS2, unless you have it specified to publish to AS3, if so, the code above is incorrect, and you will need to use AS3 methods to accomplish your task.
                  • 6. Re: Button link to html
                    awdgsxdude Level 1
                    I have a button called "News" and i use your code with News.onPress=...
                    Also tried lower case, changing the name, etc. I have it set to use AS2. I have resaved it as v8 and uploaded, here you are ..
                    http://www.mediafire.com/?2z9hjggzm22
                    • 7. Re: Button link to html
                      clbeech Level 3
                      OK, I see your problem here, thanks for publishing down. You have a series of graphics, over the top of the button(s). I would recommend changing the graphics to MovieClip symbols and then you wont need to make buttons the MC will act as one for you and use on handlers just like a button instance, then you can transition the tweening that your working on there and not have to make secondary objects. the next thing is that you should create a layer to place your actions on, call it 'actions', make a keyframe where you want you AS to execute and place all of your code there, it doesn't matter which layer the residing MC is on, as long as it is instantiated at the time of makeing the call to it.

                      You need a few things here:

                      1) make your actions layer, and put a stop() call in a keyframe where the animation is complete so that it doesn't continue to loop.

                      2) your 'News' button doesn't have an 'instance name', if you lock the graphic layer called 'Transparency' you will then be able to select the News button, when you have done so, look at the properties panel, on the left hand side there is a box that says <instance name>, you must always add an instance name to item on the Stage that you wish to 'point' to from code. Type in 'News' into the box.

                      3) you should take the button's code you have on the 'Transparency' layer and put it on the newly created 'actions' layer, after the 'stop()', then always put all your code there.

                      there you go :)
                      • 8. Re: Button link to html
                        awdgsxdude Level 1
                        Wow, thank you so much. That is incredibly helpful!
                        • 9. Re: Button link to html
                          clbeech Level 3
                          hey no prob, you're welcome :)
                          • 10. Button link to html
                            robrob1953
                            I am trying to get AS3 to do this exact same thing and am having no success. Could someone please help me with the correct call for the button?

                            This is what I am trying

                            function onBirdClick(evt:MouseEvent):void {
                            new URLRequest(" http://www.mysite.com")
                            }
                            bird_btn.addEventListener(MouseEvent.CLICK, onBirdClick);


                            Thanks

                            • 11. Re: Button link to html
                              robrob1953 Level 1
                              found it!!

                              var myURL:URLRequest = new URLRequest(" http://www.adobe.com");

                              myBtn.addEventListener(MuseEvent.CLICK, onBtnClick);

                              function onBtnClick(event:MouseEvent):void
                              {
                              navigateToURL(myURL);
                              }