5 Replies Latest reply on May 26, 2010 5:11 PM by Ned Murphy

    Click tag

    Smitch1581 Level 1

      Hi all, can anybody please help me and give me some advice on inserting a click tag in a button.

       

      I have been told i need to insert the following text

       

      on (release)
      {
      getURL(_root.clicktag, _root.target);
      }

       

      Somewhere with in the code, But this doesn't seem to work!!

      I have a trial version of CS5 so not sure if thats the problem, i get some kind of warning that the root property is not excepted and supported! The info in the help says i need to insert different text but  i cant get that too work either!!

       

      My button script at the moment looks like this...

       

      Clicky.addEventListener(MouseEvent.CLICK, fl_ClickToGoToWebPage_5);

       

      function fl_ClickToGoToWebPage_5(event:MouseEvent):void
      {
          navigateToURL(new URLRequest("http://www.vetsonline.com/annonces/html/book-an-ad/book-an-ad.html"), "_blank");
      }

       

      Any help would be appreciated!

       

      Thankyou

        • 1. Re: Click tag
          Ned Murphy Adobe Community Professional & MVP

          The first code you show is AS2, the second code you show is AS3.  The two cannot work in the same file, and your Publish Settings define which applies.

           

          The first code you show gets attached to a button symbol, it is not placed oin the timeline.  To place the code on the button you select the button and  place the code in the actions window.

          1 person found this helpful
          • 2. Re: Click tag
            Smitch1581 Level 1

            Hi ned thanx for the reply.

             

            What would you suggest i do? Change the publishing settings to support AS2 or rewrite the code for AS3?

             

            I tried changing the settings to AS2 but that didn't work, looks like i need more code to assign the button instance name and event and not sure how to do that yet!.

             

            I'm still very new to this but 4t i was getting the hang of AS3! Is it easier to change the code to work in AS3 and can you help me on that please?

             

            Thankyou very much for your help so far

            • 3. Re: Click tag
              Ned Murphy Adobe Community Professional & MVP

              The AS2 code you showed requires no instance name since it gets applied directly to the button.  As long as you have a variable named "clickTag" sitting in the main timeline, that code should work.  But for the record, placing code on objects is generally frowned upon and was discontinued in AS3.

               

              You can go the instance name route in AS2, but the code is fairly similar and doesn't get as wordy as AS3... for instance, using that button you named, the timeline code in AS2 would be...

               

              Clicky.onRlelease = function(){

                   getURL(_root.clicktag, _root.target);

              }

               

              AS3 doesn't allow placing code on objects, thus the need for the instance name.  THe button code you showed for the AS3 end of things appears to be fine. 

               

              In AS3, if you want to reference something in the root timeline you normally need to add some additional info they don't mention in the help docs... MovieClip(root).clickTag

              • 4. Re: Click tag
                Smitch1581 Level 1

                Thats perfect, thank you very much! That is greatly appreciated as i produced my first piece of Flash magic but couldn't get that link to work and was getting very frustrated!

                 

                Thank you very much for your clear answers as i now know a bit more about AS2 than i did and have some background info on what the publish settings are all about.

                 

                Thank you again

                • 5. Re: Click tag
                  Ned Murphy Adobe Community Professional & MVP

                  You're welcome