Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Creating a button that is clickTAG enabled

New Here ,
Mar 17, 2008 Mar 17, 2008

I have been hired to create a flash button for a band, and have tried to make the button clickTAG enabled so that they can track the number of hits on the button. I was wondering if someone could tell me the code required to do so, and how to go about embedding that code into the flash file. The current code I have to do so is:

on (release) {
if (clickTAG.substr(0,5) == "http:") {
getURL(clickTAG);
}
}

I've placed this code in the action panel of both the button itself, and a new actions layer, and both have not worked. I'd like to get it right this time before i send it to them for a third time. If anyone has some insight I would really appreciate some help,

thank you

TOPICS
ActionScript
640
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 18, 2008 Mar 18, 2008
tomwachter1,

> have tried to make the button clickTAG enabled so that
> they can track the number of hits on the button.

Keep in mind, clickTAG isn't a feature of Flash, per se. There isn't
really a way to "clickTAG enable" a button so much as there is a way to
perform each of the steps necessary to achieve what the clickTAG concept
does.

First, you have to wire up your button, and in ActionScript 3.0, the
on() function is no longer supported (neither is onClipEvent()). The
technotes that show how to use clickTAG are very old, so they illustrate a
Flash 5-era approach that happens to work in everything up to Flash Player
8. (Well, it even works in Flash Player 9, so long as you configure the
FLA's publish settings for ActionScript 1.0 or 2.0.)

To wire up your button, give it an instance name. Select your button
symbol on the Stage and look at the Property inspector to see where you can
supply the instance name. It's the instance name that allows ActionScript
to speak with this particular button instance, as opposed to the potentially
many other buttons on your Stage. Let's say you've used the instance name
myButton.

Select a timeline frame (I'd create a layer just for scripts) and open
the Actions panel. This code is going to go into a frame, because it can no
longer go directly on an object in AS3.

myButton.addEventListener(MouseEvent.CLICK, clickHandler);

In this line of ActionScript 3.0, you're assigning a click event to a
custom function named clickHandler(). When this button is clicked, the
clickHandler() function is triggered, simple as that. Now for that
function:

function clickHandler(evt:MouseEvent):void {
// more code in a moment
}

If you want to test the button so far, you can. You could use trace(),
for example:

function clickHandler(evt:MouseEvent):void {
trace("This button has been clicked");
// more code in a moment
}

Test so far, and you'll see the message "This button has been clicked"
in the Output panel when you click the button. Now, for that clickTAG. The
most important thing to keep in mind is that the term "clickTAG" is just a
convention, and not every agency uses that capitalization (which is a real
headache). It might be ClickTag, ClickTAG, clickTag, or some other
variation, and Flash considers each of those different. That variable
itself will be passed into Flash by something called FlashVars or possibly a
query string. If you can see the HTML that embeds the SWF, you should be
able to find the variable getting passed into the SWF. By convention, this
is simply a variable named clickTAG, so you need to find it. In AS2,
variables passed into the SWF in this way were simply available as if
declared in the main timeline. In AS3, you have to retrieve them from the
parameters property of the LoaderInfo instance associated with the root.
You can get at this LoaderInfo instance by accessing the loaderInfo property
of the root. So ...

root.loaderInfo.parameters.clickTAG

function clickHandler(evt:MouseEvent):void {
if (root.loaderInfo.parameters.clickTAG.substr(0, 5) == "http:") {
// more in a moment
}
}

Or, so save yourself a bit of typing, set that long expression to a
string variable:

function clickHandler(evt:MouseEvent):void {
var url:String = root.loaderInfo.parameters.clickTAG;
if (url.substr(0, 5) == "http:") {
navigateToURL(new URLRequest(url));
}
}


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


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 09, 2008 Apr 09, 2008

I'm hoping you can help me.
I've tried the above code in my flash banners.

clickthrough.addEventListener(MouseEvent.MOUSE_UP, clickHandler);
function clickHandler(evt:MouseEvent):void {
var url:String = root.loaderInfo.parameters.clickTag;
if (url.substr(0, 5) == "http:") {
navigateToURL(new URLRequest(url));
}
}

It works fine locally but once I run it through the ad server it trigger's the browser's popup blockers when you try to click on it. I don't understand why a popup blocker would be triggered by a user-initiated action like a click. Maybe because it's coming from a different domain.

This is happening in every browser except mac safari. I tried using

if (ExternalInterface.available)
{
ExternalInterface.call("window.open", url, "_blank", "");
}
else
{
navigateToURL(new URLRequest(url));
}
But then it won't work in safari.

I just need code I can give to my advertisers so they can happily run their as3.0 banners on our sites. As it is now they have to use AS 2.0.

If you have any suggestions that would be great. Thanks!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Apr 10, 2008 Apr 10, 2008
Here's a url where you can see this happening:

linuxriot.com
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2008 Apr 15, 2008
LATEST
dizziepeanut,

> Here's a url where you can see this happening:
>
> http://www.linuxriot.com

I don't see a Flash banner on that site (maybe I'm not looking in the
right place?).

>> t works fine locally but once I run it through the ad server it
>> trigger's the browser's popup blockers when you try to click
>> on it. I don't understand why a popup blocker would be
>> triggered by a user-initiated action like a click. Maybe
>> because it's coming from a different domain.

The different domain aspect might the culprit, but it might also be due
to the value of thar url variable. Does that variable reference JavaScript
in the HTML?


David Stiller
Adobe Community Expert
Dev blog, http://www.quip.net/blog/
"Luck is the residue of good design."


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines