5 Replies Latest reply on Oct 8, 2007 1:15 PM by Newsgroup_User

    clickTag tracking with AS 3.0?

    Rusherific
      So this is pretty much the standard applied to a button (in AS 2.0), that will get the clickTag url assigned by the page your advertising on right:

      on(release) {
      getURL(clickTag, "_blank");
      }

      Which, when tested locally will open a browser window with the address "undefined" (a good thing)

      However I was trying to figure out how to do this in AS 3.0 (but luckily the ad I'm doing doesn't have any other code, so I just reverted to 2.0 this time) and so I tried this (in a frame of course) :



      var request:URLRequest = new URLRequest(clickTag);

      clickthrough.addEventListener(MouseEvent.MOUSE_UP, sender);

      function sender(event:MouseEvent):void {
      navigateToURL(request, "_self");
      }

      But that ^ does nothing. It seems there's something else that needs to be added. I worry in AS 3.0 that you need to tell it explicitly that there is a variable clickTag that will be defined by the page it's in, and I don't know how--or if there's just a mistake in there.
        • 1. Re: clickTag tracking with AS 3.0?
          Level 7
          Rusherific,

          > var request:URLRequest = new URLRequest(clickTag);

          > But that ^ does nothing.

          You nailed it, and the reason for that is because passed-in variables
          are no longer associated with the main timeline in ActinScript 3.0. In AS2,
          FlashVars or query-string variables are loosely collected in the main
          timeline: they simply become normal string variables, as if they had been
          declared there. In AS3, you must retrieve such variables from a LoaderInfo
          instance associated with the main timeline.

          Here's a short article that goes into more detail. It's not
          specifically related to clickTag, but the important thing to realize is that
          clickTag isn't an inherent feature of Flash. It's nothing more than an
          arbitrarily named variable that is passed in via FlashVars. The key here is
          FlashVars, and this article explains how to nab those variables:

          http://www.quip.net/blog/2007/flash/how-to-retrieve-flashvars-data-in-actionscript-30

          See if that gets you started, and be sure to write back if it still
          doesn't make sense. I've been meaning to write a clickTag article for the
          Adobe Dev Center, and your question might just light the fire under the
          right spot for me. ;)


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


          • 2. clickTag tracking with AS 3.0?
            Rusherific Level 1
            Thanks for the help. So basically

            var request:URLRequest = new URLRequest(clickTag);

            is replaced with

            var request:URLRequest = new URLRequest(root.loaderInfo.parameters.clickTag);

            My only question is that even with this update the flash still doesn't actually navigate to an "undefined" address as the 2.0 code does locally. Is this just because the navigateToURL function operates differently and ignores an undefined link, or is it still not working?

            I guess I just have a general gripe with Flash that they would create a whole new AS (basically from the ground up in terms of philosophy), which I'm sure is great for seasoned Javascripters, but for the rest of us their only concession being a command-for-command 2.0 migration page, and they ship CS3 with most all their practical AS examples still being 2.0...
            • 3. Re: clickTag tracking with AS 3.0?
              Level 7
              Rusherific,

              > [previous code] is replaced with
              >
              > var request:URLRequest = new
              > URLRequest(root.loaderInfo.parameters.clickTag);

              That's the key change for locating the FlashVars data (in this case, the
              arbitrarily named clickTag variable), but event handling has been revamped
              in ActionScript 3.0, which means the on() function is no longer valid -- but
              you already covered that. So yes, looks like you're set. :)

              > I guess I just have a general gripe with Flash that they would
              > create a whole new AS (basically from the ground up in terms
              > of philosophy) and then their only concession being a command-
              > for-command 2.0 migration page.

              You have to admit, there's more on the Adobe site than that. ;) There
              are quite a few "intro to ActionScript 3.0" articles/overview, and new
              developer articles in the Dev Center all the time.

              > And they ship Flash CS3 with most all their practical AS examples
              > still being 2.0...

              ActionScript 2.0 is still heaviliy in use, so it makes sense to keep the
              old articles around. I think one of the biggest issues on the forums lately
              is the mistaken assumptoin that Flash CS3 necessarily equates to
              ActionScript 3.0. True, FLAs are configured to default to the new language,
              but it's easy to choose "ActionScript 2.0" when creating a new document, or
              to change the Publish Settings of an existing document.

              That said, I can certainly empathize with a sense of overwhelming at the
              learning curve required for ActionScript 3.0. If I was more into Flex
              (which also outputs Flash content), I would have started with AS3 a full
              year before I did. In any case, the more I use AS3, the more I appreciate
              the way it's structured. The first couple bumps are pretty crazy, though.


              David Stiller
              Contributor, How to Cheat in Flash CS3
              http://tinyurl.com/2cp6na
              "Luck is the residue of good design."


              • 4. clickTag tracking with AS 3.0?
                Rusherific Level 1
                Yeah, I'm not against AS 3.0 or keeping 2.0 support, and while I'm well past some basics like event handlers for everything, it feels pretty lonely sometimes trying to learn it, especially with things like this that over time have been well documented in 2.0 and then it's like, oops doesn't work in 3.0 anymore. Good luck googling.
                • 5. Re: clickTag tracking with AS 3.0?
                  Level 7
                  Rusherific,

                  > it feels pretty lonely sometimes trying to learn it, especially
                  > with things like this that over time have been well documented
                  > in 2.0 and then it's like, oops doesn't work in 3.0 anymore

                  This happened somewhat during the early days of ActionScript 2.0, too,
                  though maybe not as loudly. Most of the benefits/changes in AS2 occur when
                  the developer is writing custom classes, so timeline examples are often
                  indistinguishable if the sample code leaves off the post colon syntax
                  (:Number, :String, :Void, etc.).

                  Sooner or later, the online samples will catch up. :)


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