Davor Peic.Gavran Portfolio
Hrvatski English Español
04Mar
2010

Using external variables for flash banners, in AS2 and AS3

Permalink 0 Posted in: Tutorials Useful

I’m doing a lot of banners, and it’s very common that Ad Company asks for variable implementation, so they can send their campaign link, and maybe other information like target and style.

Every once a while they forgot to notice what are the names of that variables, as they use applications to show banners, these variables are fixed, and it’s very rare that they will change it only for your banner, so it’s important that you know that names before sending the final banner.

For those Ad Companies who send a document with how to make a button in Flash, you can see which names they used, normally the names are “clicktag” and “clickTag” (this small difference can make your banner useless). That looks something like this:

AS2 (Applied on button)

But what if your banner is made in AS3?

You can’t use solution for AS2 because AS3 document don’t accept actions on buttons, so you need to make your own. Here is one way to get external variables, as you can see, it’s much “complicated” then AS2 version, and must be applied on frame:

banner_btn.addEventListener(MouseEvent.CLICK,openLink);
function openLink(e:MouseEvent){
var request:URLRequest = new URLRequest(root.loaderInfo.parameters.clickTag);
navigateToURL(request, root.loaderInfo.parameters.target);
}

As you can see, to open new link from flash, you need the link and target, so this code is waiting for “clickTag” and “target” variable. Target is not so needed, default is “_blank”.

How do I send variables?

To have working banner, you need to prepare encoded link, and use it when calling a flash movie like this (opens http://www.google.com in the same window):

banner.swf?clickTag=http%3A%2F%2Fwww.google.com&target=_self

I hope this little tutorial helps you with your banners.

About
AboutMy name is Davor Peich-Gavran. I'm 28 years old freelance designer from Croatia. I moved to México about two years ago. Hope you like my blog/portfolio.
Cosmosart is powered by ExpressionEngine
Copyright

This site, that means all my designs and photos are under Creative Commons Licence.

That means that you can use my work, but only if you don't change it or publish under other name. If you planing to use somewhere my work, contact me!