if you're used to actionscript2 in flash and making banners, you're used to:
on (release){
getURL(clickTag,"_blank");
}
But AS3 ushers in a new dawn where the language is more object orientated and comes away from those handy little tricks. First thing you have to do is bring in the click tag variable from root, something like:
clickTAG = root.loaderInfo.parameters.clickTag;
Then you need to catch the action:
public function HandleClick(param1:MouseEvent) : void
{
trace("click");
ExternalInterface.call("window.open", clickTAG, "arplayer", "height=372,width=820");
return;
}
now the above is actually an example of how to open a window of a custom size.
Now I was dealing with a case recently where the clickTAG = was brought in on the root frame - so in otherwords it was within a function called frame1(). Now this means that clickTAG is only defined for this function and not for the event handler function. Instead the event handler has to be changed to:
public function HandleClick(param1:MouseEvent) : void
{
trace("click");
clickTAG = root.loaderInfo.parameters.clickTag;
ExternalInterface.call("window.open", clickTAG, "arplayer", "height=372,width=820");
return;
}// end function
Now I'm not a flash designer/programmer - but I am a coder and so this was blatantly obvious to me using sothink decompiler, but not so much for the creative agency.
Thursday, December 18, 2008
Tuesday, December 16, 2008
Randomize an array
First of all the why:
you want to serve back several text ads in a random order through one adserver call. You would do this to save on calls - for instance a block of 8 text ads which are changed on a weekly basis could instead be changed in to one block that gets updated, randomized with javascript, and printed on the screen. This saves 7 extra calls a pop - which means that you save on adserving fees.
The current methods:
There are two methods suggested. The first is faulty, and if you're using it - stop now:
1)
Array.sort(function(){return (Math.round(Math.random())-0.5);});
now the idea behind this is that you use the sort method for an array, but randomly decide which of the two elements is higher. This does not work because the implementation of the sort method can be different between javascript engine implementations. In fact, give it a go. Make a new array of 10 digits and print out the results a hundred times. The answers are definitely not random.
2)
The second method is the Fisher-Yates which has been used to shuffle cards completely randomly in the past. Although a good algorithm, it requires a second array and too many swapping routines:
function fisherYates ( myArray ) {
var i = myArray.length;
if ( i == 0 ) return false;
while ( --i ) {
var j = Math.floor( Math.random() * ( i + 1 ) );
var tempi = myArray[i];
var tempj = myArray[j];
myArray[i] = tempj;
myArray[j] = tempi;
}
}
So how should it be done?
THE ANSWER:
for(i=0;i<array.length;i++)
array.splice(Math.round(Math.random()*i),0,array.pop());
using the power of javascript array functions we can make this work with most of the calculations being done by the libraries - which are always nicely optimised.
So how does it work?
we only use the one array, but we divide it in to two separate logical parts. The randomized array, and the elements yet to be put in to the array.
What we do is grab the last element of the right side of the array (elements to be randomized) then place it randomly in the left side of the array (elements already randomized). This is much quicker with smaller data-sets than fisher-yates, but I will give no guarantees for data sets over 100.
enjoy!
The free ad serving solution
So what do you get when you have a small blog and want to make a little money out of it?
a) Google AdManager
b) Adwords Account
c) Google Analytics
Google have come a long way from their original stance of "Don't be evil" - and let's face it. More of us have begun to hate them (even though we just can't ween ourselves off their search engine)
So what are the alternatives?
Well there are a few nice adservers going around
1) Open X - http://www.openx.org/
This is good for those casual coders out there that want to do it all themselves and like to own their own data on their own servers. Anyone with a webhost has probably seen OpenX as an option - although it is probably listed under one of it's former names in plugin libraries - OpenAds or PHPAdsNew.
2) Rubicon - http://rubiconproject.com/
A new adserver to the fray. It offers a nice sleek front end which, really, we all love to see. It is still a hosted solution, but would be good for those who are used to a google admanager
3) APT! from Yahoo - http://apt.yahoo.com/
What can I say? It's Yahoo's answer back to google admanager. It is new and hasn't really caused the stir it should. I am looking forward to seeing what the take up will be.
Adwords Account alternatives:
Instead of going over this I did a search on google (ironic right?). Just go here http://www.rosswalker.co.uk/adwords_top10/
Google Analytics alternatives:
1) Piwik - http://piwik.org/
This is closely affiliated with OpenX, so if you're happy with OpenX - go Piwik!
2) Woopra - http://www.woopra.com/
This has another sleek interface, so if you liked the look of rubicon - you'll love this. But perhaps the best thing about Woopra is it's real time stats that you can watch change in front of your eyes. Great if you've got a popular blog and want to show off the digg effect to your mates.
3) Engine Ready - http://www.engineready.com/products/index.html
Possibly the most google analytics like of the bunch. If you want a smooth transition over - then give this one a go
Tuesday, December 9, 2008
Flash 10 fires popup blocker on flash click
This is a serious bug for everyone in the business to know. What exactly makes it occur is unknown, but you can spend hours looking for a solution that isn't there
Basically flash compiled in a version less than 8 may trigger ie6 and ie7s in built popup blocker when a user clicks on the flash button and the common getURL method is used.
for more information see:
Introduction
There are a few good blogs and resources for workers in the online advertising space, and below is just a few:
not to mention the groups on linkedIn of which the below is probably the best:
and if you leave a discussion there I will probably answer.
But this blog aims at the more technical in the field - those people who actually know what a DOM is, rather than throwing it in there as a buzzword, or at least for those that want to learn.
I will be providing useful bits of code, answering questions about tags, discussing conventions, handing out free advice and even dissecting the current state of the market.
So sit back, enjoy, and feel free to ask me any questions.
cheers,
Rhys
Subscribe to:
Posts (Atom)