AS3 clickTag case and popup blocker fix

Last week we've been struggling to get our AS3 banners ready for publication.
One of the more common problems anyway, is that some ad management systems requiress clickTag (lowercase "ag") and others requires clickTAG (uppercase "AG") in order to load the right URL. This is very annoying, especially when you have to make 2 versions for different publishers and you need to do a text change... When you have a big capaign with let's say 5 banner formats, and 3 banner variants, you already have to make 15 different banners. In case you need to deliver banners with a clickTag and a clickTAG, you'll end up with 30 banners. In case you've ever build banners yourself, you see my point. It's soo easy to lose the overview when you have so many files looking almost identical to each other.

A new problem with banner build using AS3, is that some browsers will block the navigateToURL requests. A trick for this is let javascript open the URL instead of actionscript.

Both of these things have been recently an issue, so that's why I decided this weekend to wrap this all up in a clickTag class, which is universal for all different case combinations of the word clickTag. Beside that, it will open URL's correctly without a browser which is blocking it. (at least, as far a I know).

Instead of adding a button on the stage, set up all the event listeners etc, you can now use:

 
var clickTag:ClickTag = new ClickTag(300,250);
clickTag.enableClickTag();
addChildAt(clickTag,0);

It's just as simple as that. In case you want a custom shaped button, you need to assign it to clickTag by using "clickTag.setButton(btn);".

In order to open the links correctly, you need to make sure that the parameter AllowScriptAccess is set to "always":

<param name="AllowScriptAccess" value="always">

Download this class and it's examples in Flash and Flex here!

10 Responses to “AS3 clickTag case and popup blocker fix”

  1. I feel your pain man, making banners can sometimes be very tedious. I live in Montreal where we speak both English and French, so when we make a banner campaign we do it in both languages. This doubles the already big number of banners files (also doubles the numbers of animated gif).

    I don’t know if it is really used but the Interactive Advertising Bureau of Canada released an Universal ClickTag:

    http://www.iabcanada.com/clicktag/

    This could help reduce the number of files.

  2. Hey zedia.net!

    Your link is not for AS3, noOb!
    I will kick your ass

  3. Very cool, i appreciate this! when shops i freelance for start letting us use as3, i will rock this shit!

  4. Thanks for sharing, Paul.
    In my case (and i think in most of the cases) this is not working, because the banner swf is on a different server than the embedding html code. I get a SecurityError: Error #2060: security sandbox violation: ExternalInterface caller (server hosting swf) cannot access (server hosting html code).
    at flash.external::ExternalInterface$/_initJS()
    at flash.external::ExternalInterface$/call()
    at com.paultondeur.banners::ClickTag/openURL()
    at com.paultondeur.banners::ClickTag/onClick()

  5. AllowScriptAccess IS set to “always”…

  6. Hi,
    thanks for the class, its very useful for me but I’m also dealing with the security sandbox violation issue as Stefan mentioned.

    my banneranimation.swf is on different server, so I try to load it from banner site. no popup block its ok, but violation problem occures.

    has anyone solved this problem?
    thanks in advance.

  7. I hade the same issue, i loded in a as2 file and handel clickTag from the as2 file

    as3 code
    /////
    var tempArr:Array = loaderInfo.loaderURL.split(”/”);
    var uu:uint;
    var daRooTS:String = “”;
    do
    {
    daRooTS +=tempArr[uu]+”/”;
    uu++;
    }while(uu<tempArr.length-1)

    var goto:String = root.loaderInfo.parameters.clickTAG;

    var request:URLRequest = new URLRequest(daRooTS+”klickFix.swf?myClick=” + goto);
    loader.load(request);
    addChild(loader);
    /////

    as2 file in this case named klickFix.swf
    ////
    // a mc calld onTop_mc on stage alpha = 0
    onTop_mc.onRelease = function()
    {
    getURL(_root.myClick, “_blank”);
    };
    ////

    Its’s works fine for me

  8. I think, you are making this ClickTag thing a bit too difficult for yourself. clickTAG and clickTARGET are in CS4 built in flashvars. Code is very simple:
    make a layer, make its alpha 0 (no matter if from script or drawed), put it so big to be as big as the AD itself, and convert it to symbol. Inside you allow it to be handeled as button with a short script. Make sure, to give an instance name to it. Then make a function with navigateToURL and the flashvars.
    With a drawn object, instance name clickArea, the code is very simply the one below:

    Button mode enabling inside clickArea symbol:
    stop();
    mouseChildren = false;
    buttonMode = true;

    Main timeline script:
    function mouseClick (e: MouseEvent): void {
    navigateToURL (root.loaderInfo.parameters.clickTAG, root.loaderInfo.parameters.clickTARGET)
    }
    clickArea.addEventListener(MouseEvent.CLICK, mouseClick);

    That is it. My oppinion. I love AS3, it makes Flash look like the first version of a next generation programming language.

    Bye,

    Ben

  9. Just adding clickTag or eny other flashVars is rely easy, like you said. The problem is that IE blok the navigateToTRL(”sajt”) in a (as3)banner. So there fore my code.
    I had a problem in my code (above). If there whare (&) in the clickTag.. But you can fix this by doing this..
    In as3: (goto = goto.split(”&”).join(”_$$_”))
    In as2: (gooTo = _root.myClick.split(”_$$_”).join(”&”);)

    (just replace the & sign to something and then change it back to & again.

    regards Håkan

  10. IE8 is catching it, and Google Popup blocker is doesn’t allow it.

    Can anyone help me please!

Discussion Area - Leave a Comment