on(release)
{
if (clickTAG.substr(0,5)=="http:")
{
getURL(clickTAG, "_blank");
}
}
into an ActionScript 3 "main timeline" format hopefully using an event
listener to a button I have created.
I'm with ya. There are usually a number of ways to solve any given
problem in Flash (actually, in programming in general). Here's a clickTAG
approach in ActionScript 3.0:
myButton.addEventListener(
MouseEvent.CLICK,
function():void {
if (root.loaderInfo.parameters.clickTAG.substr(0,5)=="http:") {
navigateToURL(
new URLRequest(root.loaderInfo.parameters.clickTAG),
"_blank"
);
}
}
);
Keep in mind, the concept "clickTAG" is not, per se, a feature of Flash.
What's going on here is something called FlashVars, which is one of many
mechanisms for getting external data inside a SWF at runtime. It just
happens that ad tracking agencies have loosely agreed to a naming convention
for this particular piece of data. Most companies call it some version of
clickTAG (might be ClickTAG, ClickTag, clickTag, and other variations).
ActionScript 3.0 is case sensitive, so the capitalization matters.
In the above suggestion, the same thing happens as in the original
pre-AS3 suggestions on the Adobe site: the SWF checks to see if a variable
named clickTAG contains a string. Actually, it checks whether the first six
characters (0 through 5) are "http:". If so, a URL request is made to
whatever URL is stored in the clickTAG variable. The URL is generally a
hyperlink that uniquely identifies this particular ad for tracking purposes.
The URL is provided from outside the SWF altogether, so it's not something
you can easily test for in Flash without having the HTML that embeds the
SWF.
David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."
Just curious. Which site is asking you to provide something in AS3? I've been
waiting to see when the standard for Flash Player versions to be increased to
Flash Player 9. In my experience, most sites will not allow any version higher
than 7 which means I am stuck with AS2. Let me know if you don't mind. Thanks!
I know that this post is super old, however here is the proper code to
use clickTAG and have it work with google adserve in AS3. Just replace
every & in the clickTAG Url with a ~ and you'll be set. It converts it
back on the other end. The reason you have to do this is because & is
reconigized in AS3 and ~ is not.
[code]
ButtonName.addEventListener(MouseEvent.CLICK, functionName)
{
function functionName(event:MouseEvent) : void
{
if (root.loaderInfo.parameters.clickTAG.substr(0, 5) == "http:")
{
Url = String(root.loaderInfo.parameters.clickTAG).split
("~").join("&");
navigateToURL(new URLRequest(Url), "_blank");
}// end if[/code]