Yearly Archives: 2011

AS3 clickTag & IE popup blocker

Recently, we at Gynzy had to implement clickTag scripts in Actionscript 3 banners. As you might know, AS 3 banners don’t work well in Internet Explorer. You’ll get a pop-up blocked warning when using navigateToURL().

After some googling I found a clickTag script at
blog.advalidation.com/2011/06/as3-clicktag.html
It uses ExternalInterface.call('window.open', url, '_blank'); when the user agent of the banner is MSIE. This script worked almost perfect, it only had two requirements:
1) AllowScriptAccess needs to be true either by setting it to “always” or by setting it to “sameDomain” and loading the flash from the same domain as the hosting page.
2) The .swf file has to be embedded in html.

If the requirements are not met, actionscript will throw an error without opening the requested url (only in Internet Explorer of course). I tried to work around this problem by catching the error and use navigateToURL in case ExternalInterface.call fails. See my script below:
Continue reading

AS3 Object shuffle or randomize

After I published my AS3 Vector shuffle or randomize post, Philip Bulley commented: “…I tried casting a Vector.int to Vector.*, but the vector becomes null within the shuffle method”. I never had to randomize a Vector.<int> but when I tried I discovered Philip was right, the result was null.

I solved this problem by changing my shuffleVector function into a more generic shuffleObject function. It solves all casting problems and you can use the shuffleObject function to randomize Objects, Array and Vectors. So if you want to randomize or shuffle an Object, Array or Vector, please use this function below instead of my previous shuffleVector function.
Continue reading

TextSnapshot.getTextRunInfo: where is corner0x?

For a new Gynzy tool, I’m trying to detect coordinates of selected words in a static textfield. It’s not to difficult using the TextSnapshot object. The getTextRunInfo method returns an array of objects in which each object contains information about a specific character, including corner0x, corner0y, corner1x, corner1y, corner2x, corner2y, corner3x, and corner3y (the corners of the bounding box of the character).

It was a bit of a puzzle how to use these values, because Adobe didn’t document where corner 0, 1, 2 or 3 is situated. That’s why I’m publishing this list:

  • corner0x & corner0y : bottom left corner
  • corner1x & corner1y : bottom right corner
  • corner2x & corner2y : top right corner
  • corner3x & corner3y : top left corner

If you want to know what’s possible working with static textfields, have a look at this project: flashpages.