12 Replies Latest reply on May 25, 2009 9:43 AM by TNT-vip

    Beginner problem with link in a banner

    TNT-vip

      Hej all,

       

       

       

      I have just started my journey with Flash. I cannot find solution to „my big problem”. I need my newly designed banner become a link.

       

      It will be placed on webpage and clicking on it should open in same page (or new tab) a destination page from link.

       

      I know its maybe obvious for you, but its really killing my workflow and sucking all my power.

       

      How can I do it ?

        • 1. Re: Beginner problem with link in a banner
          evbarkley9

          Try this

           

          navigateToURL( new URLRequest("http://www.YOURURLHERE.com"), "_self" );

          1 person found this helpful
          • 2. Re: Beginner problem with link in a banner
            Ned Murphy Adobe Community Professional & MVP

            If you're using AS3, the line of code just provided will be part of the solution, but you'll need to make some element of your banner a clickable object that you can assign button-like functionality.  The element will need to be a movieclip or a button (maybe an invisible button that covers everything).

             

            If you don't know how to code for clicking something just say so.

            1 person found this helpful
            • 3. Re: Beginner problem with link in a banner
              TNT-vip Level 1

              The command go to url is working the way needed  Thanks for that.

              nevertheless still duno how to input it.

               

              Ned Murphy, could you please give bit more information how to input a mouse click down script to button (on the click go to link)

               

              I have found one script which might do but dont know whether its good and what to put/code there:

              import fl.controls.BaseButton;

              MouseEvent MOUSE_DOWN

               

              Beside, how to make my button invisible ?

               

              Thank you in advance!

              • 4. Re: Beginner problem with link in a banner
                Ned Murphy Adobe Community Professional & MVP

                Create your own button, don't use what you were looking at.  Just draw a rectangle, select that rectangle, right click it, and select Convert to Symbol.  Select the button symbol in the interface that appears, and rename it to invisible button or something else appropriate to its purpose.  Sometimes you may be wanting to use several of the same button in a movie, so naming it to be noticeable in the library helps.

                 

                Now double click that button to open it for editing.  It should have the rectangle you drew displayed in the first frame.  Click down on that frame and drag it to the 4th (Hit) frame.  You're done creating your invisible button, so double click on the stage to get back out of the button. You will see the button as a semi-transparent turquoise color... it will be invisible when you play the movie.

                 

                Select the button again and resize it to whatever size it needs to be.  Then give it an instance name in the properties panel, let's say you give it an instance name of btn1.

                 

                In AS3, to make a button work with code, you need to add an event listener for it.  You might need to add a few (for different events, like rollover, rollout, clicking it, but for now we'll just say you want to be able to click it to get a web page to open.  In the timeline that holds that button, in a separate actions layer that you create, in a frame numbered the same as where that button exists, you would add the event listener:


                btn1.addEventListener(MouseEvent.CLICK, btn1Click);


                The name of the unique function for processing the clicking of that button was already defined at the end of the event listener assignment, so now you just have to write that function out:


                function btn1Click(evt:MouseEvent):void {

                   var url:String = "http://www.awebsite.com/awebpage.html";

                   var req:URLRequest = new URLRequest(url);

                   navigateToURL(req);

                }

                 

                I presented the code that way, so that you are aware of the the different parts that are involved.  You can substitute the shorthand version that you were provided for the function.

                 

                function btn1Click(evt:MouseEvent):void {

                   navigateToURL( new URLRequest("http://www.awebsite.com/awebpage.html");

                }

                • 5. Re: Beginner problem with link in a banner
                  TNT-vip Level 1

                  Still puzzled...

                   

                  I have got to point with inputting code and then I have stopped...

                   

                  I’m choosing in the timeline the new, separate, time line with „invisible button”. Im choosing it and clicking on „Action” - F9

                   

                  And then i duno. Trying different combination including putting code together. However its not working

                   


                  btn1.addEventListener(MouseEvent.CLICK, btn1Click);


                  function btn1Click(evt:MouseEvent):void {

                     navigateToURL( new URLRequest("http://www.awebsite.com/awebpage.html");

                  }

                   

                   

                  Im getting error 1084: Syntax error: expecting rightparen before semicolon. navigateToURL( new URLRequest("http://www.awebsite.com/awebpage.html");

                   

                  What Am I doing wrong ?

                  • 6. Re: Beginner problem with link in a banner
                    evbarkley9 Level 1

                    you forgot a parentheses at the end. Add it like below and you should be fine.

                     

                    Also I just want to be sure that you have given an instance name to your button. In your case it should be btn1. Click your movie clip on stage and then go to the properties panel if you have not.

                     

                     

                     

                    btn1.addEventListener(MouseEvent.CLICK, btn1Click)

                    function btn1Click(evt:MouseEvent):void {
                       navigateToURL( new URLRequest("http://www.awebsite.com/awebpage.html"));
                      
                       trace("navigated")
                    }

                    • 7. Re: Beginner problem with link in a banner
                      TNT-vip Level 1

                      Tried copying your code, also not working .

                       

                      Could I ask you, to have a look on my banner (banner2.fla) which I attached to my post.

                      The „invisible button” is lying on first motion layer called btn1.

                       

                      Maybe it will be easier for me to get what I'm doing wrong

                       

                      Message was edited by: TNT-vip

                      • 8. Re: Beginner problem with link in a banner
                        Ned Murphy Adobe Community Professional & MVP

                        I don't have CS4, so I cannot open the file.  But maybe someone else can if they stumble along.  I can open a CS3 version of it if you make one available.

                         

                        If you adjusted your code to add the right parethesis, then the code should be correct now, so the most likely issues would be either instance naming or locations of code vs. button.

                         

                        Did you assign an instance name, in the properties panel, to the button?  That name needs to agree with the name you use in the code.  IF that's all in agreement, then that code needs to present in the same timeframe as the button (preferably on a different layer, just the same frame).

                         

                        If you are still getting any error messages, you should provide them.  They are helpful in identifying problems.

                        • 9. Re: Beginner problem with link in a banner
                          TNT-vip Level 1

                          Ned Murphy, I have upload the cs3 version. Hope it will give a hint what have I missed up

                           

                          Thank you for so big help !!

                          • 10. Re: Beginner problem with link in a banner
                            evbarkley9 Level 1

                            Ok your file should be working now.

                             

                            What I saw was that you had the function for your button on 2 frames, the 1st and the last. That was not necessary. Having the code on the first frame only is fine because your invisible button lasts the entire length of the time line. It was the first frames code that was still missing the second parentheses before the semi-colon.

                             

                            2nd, your invisible button did not have an instance name.

                             

                            make sure all your buttons and movie clips have an instance name. you can name them by clicking the button/movie clip and then going to the properties panel. You can name it there.

                             

                            hope this works for you.

                            • 11. Re: Beginner problem with link in a banner
                              TNT-vip Level 1

                              oh! :)

                              wasn't so hard

                              Have MUCH MORE to learn about flash .

                               

                               

                               

                              evbarkley9 ,  Ned Murphy

                               

                              Thank you guys for so big help and patience in doing your best to solve my problem !!!

                               

                              Really ure great and once more BIG THANKS for time !!!

                              • 12. Re: Beginner problem with link in a banner
                                Ned Murphy Adobe Community Professional & MVP

                                You're welcome.  Hopefully you checked and understand the changes that were done for your file.