4 Replies Latest reply on Dec 18, 2007 3:15 PM by Newsgroup_User

    Banner Ad code help

    bubbajoebingo
      I am really a designer not a code person that was asked to do a banner ad. I was asked to place some tracking code in my ad and now I am getting syntax errors. Anyone know what I am doing wrong?

      inv_btn.onRelease = function(){
      if (clickTAG.substr(0,5) == " http://www.mouldings.com/trade_signaturedealer1.shtml") {
getURL(clickTAG, "_blank");
      }
      };
        • 1. Re: Banner Ad code help
          Level 7
          bubbajoebingo,

          > I was asked to place some tracking code in my ad and now
          > I am getting syntax errors. Anyone know what I am doing wrong?

          What syntax errors are you getting?

          > inv_btn.onRelease = function(){
          > if (clickTAG.substr(0,5) ==
          > " http://www.mouldings.com/trade_signaturedealer1.shtml")
          > {?getURL(clickTAG,
          > "_blank");
          > }
          > };

          The above is written in ActionScript 2.0. If your document is
          configured for ActionScript 3.0 (for example, if you're using Flash CS3 and
          chose an AS3 document), you'll have to set it to AS2 in the Publish
          Settings.

          Even if your FLA is set for AS2, the line inside the if() statement
          looks wrong. The whole point of the clickTAG variable is that the necessary
          URL gets passed into the SWF from the HTML document (may not be under your
          control at all). So you shouldn't be comparing the clickTAG variable to a
          known URL ... because you usually won't know what URL that'll be.

          This clickTAG business comes up quite a bit on the forums, to the point
          were some people get the idea that "clickTAG" is an inherent feature of
          Flash, but it isn't. The feature that's being used here is something called
          FlashVars, which is a mechanism that allows variables to be created in a SWF
          from an outside source. The HTML document that embeds this SWF is going to
          have to provide a clickTAG variable (this is an arbitrary name) and feed it
          a value -- which is going to be the URL of your ad tracking software. This
          allows you, the designer, to use getURL() without having to know which
          software (which URL, etc.) is tracking the banner.

          Does that make sense?

          Your code should actually be something like this:

          inv_btn.onRelease = function():Void {
          if (clickTAG.substr(0,5) == "http:") {
          getURL(clickTAG, "_blank");
          }
          }

          ... and the point of the if() statement is only to ensure that the beginning
          of the supplied URL -- again, this comes from the HTML document, rather than
          you -- starts with "http:". The getURL() line provides clickTAG as the
          first parameter and "_blank" (if you like) as the second parameter.


          David Stiller
          Co-author, Foundation Flash CS3 for Designers
          http://tinyurl.com/2k29mj
          "Luck is the residue of good design."


          • 2. Re: Banner Ad code help
            BSpero Level 1
            Do you have another other code that you are using? In what you have here, you ask if the first five characters (substr(0,5)) of a variable (clickTag) are equal to an entire web address. This is not going to be true since the web address has a lot more than 5 characters. Then, if this is true, you try to load a page. If you have not set the variable clickTag, then this will not work. What is the error that you are getting?
            • 3. Re: Banner Ad code help
              bubbajoebingo Level 1
              thank you for the explanation, i did not think that this made sense. I am getting the following errors:

              **Error** Scene=Scene 1, layer=actions, frame=1:Line 2: Syntax error.
              if (clickTAG.substr(0,5) == " http://www.mouldings.com/trade_signaturedealer1.shtml") {
getURL(clickTAG, "_blank");

              **Error** Scene=Scene 1, layer=actions, frame=1:Line 4: Unexpected '}' encountered
              };

              Total ActionScript Errors: 2 Reported Errors: 2
              • 4. Re: Banner Ad code help
                Level 7
                >> if (clickTAG.substr(0,5) ==

                you're missing the closing paren - if (clickTAG.substr(0,5)) ==


                --
                Dave -
                Head Developer
                http://www.blurredistinction.com
                Adobe Community Expert
                http://www.adobe.com/communities/experts/