GreenSock Animation Platform (GSAP) v12 – Now supporting JS

May 16th, 2012 by Adrian

GreenSock Animation Platform (GSAP) v12

Mr Jack “Green Sock” Doyle has just released version 12 of his GreenSock Animation Platform (GSAP) for Flash AS2 and AS3, but the big announcement is that it now supports JavaScript too!

This is awesome news, and the API for JavaScript is the same as we have been using all these years for Flash projects. Plus the performance is amazing! I’ve just quickly run a few tests on my computer and it is way faster than jQuery, YUI 3, MooTools and Zepto. Try running the speed test yourself to see just how fast it is. I’ll post some speed test figures here soon.

Jack has managed to include TweenLite, TweenMax, TimelineLite, and TimelineMax in to the JavaScript version, plus there is also a new CSSPlugin that enables css-related animations.

There have also been some other general improvements, changes and optimisations throughout the platform.

Great work Jack. If you use this library in your work why not help Jack to continue working on it by becoming a Club GreenSock member?

Posted in Actionscript 1.0 & 2.0, ActionScript 3.0, Animation, Javascript, Tweening | No Comments »

Starling 1.1 has been released

May 9th, 2012 by Adrian

Starling logo

Starling (the hardware accelerated 2D framework for Flash using Stage3D) has been updated to version 1.1.

Some of the new features include …

  • Support for Multi-Resolution Development: Create your game for just one resolution and deploy it to any screen out there, simply by providing different sets of textures.
  • Use Blend Modes for interesting optical effects, without any sacrifices on performance.
  • Enjoy a Performance Improvement on the 1st Generation iPad and comparable devices. Benchmark results skyrocketed by 500%!
  • Display Live Statistics (framerate, memory consumption) through the new “showStats” feature.
  • Profit from numerous bugfixes and performance improvements throughout the code base.

You can download the latest version from here …

If you are looking for some useful resources to get started, check these links out …

Posted in ActionScript 3.0, AIR, Flash, Starling, Tutorials | No Comments »

Creative Coding Podcast

March 4th, 2011 by Adrian

Creative Coding Podcast

A new podcast has been brought to my attention called the Creative Coding Podcast.

Hosted by Seb Lee-Delisle and Iain Lobb, two names I’m sure you will recognise from the UK Flash scene.

They will be discussing the ins-and-outs of programming for visual and creative applications. The first episode only went out on 30th January 2011, so it is still early days. Give them your support by subscribing in iTunes now.

Here are direct links to the three episodes so far …


UPDATE – October 29th 2012 – New episodes have been added below …

Posted in ActionScript 3.0, Adobe, AIR, Android, Augmented Reality, BlackBerry, Flash, Flash Catalyst, Flex, Game, Generative Art, Infographics, iPhone, Mobile, OpenFrameworks, Papervision 3D, Physical Computing, Podcast, Processing, Websites | 2 Comments »

Accessing Google’s URL Shortening API from Flash (AS3)

January 17th, 2011 by Adrian

Google URL Shortener

Last Wednesday (12th Jan 2011) Google released an API for accessing their URL shortening service, which is great for web developers. However, for us Flash developers things aren’t quite so simple as it is for everyone else. This is due to the security restrictions imposed when accessing the domain. There is a crossdomain policy file at the root of their server ( but it is very restrictive and of no use to us, causing security errors inside your Flash movie once it has been deployed online. cross domain policy file

So I have written an ActionScript class and PHP script which makes the whole process easier for everybody. Here is a demo of it in action …

The source files and this Flash CS5 demo can be downloaded from GitHub.

The PHP file acts as a proxy so we circumvent the security restrictions. The code also makes use of as3corelib for the JSON decoding.

Many thanks to Vijay Joshi for his example of using cURL to send the JSON data from PHP to the Google web service.

Posted in ActionScript 3.0, Google, Sample Code | 3 Comments »

AS3 Encoder/Decoder for Special Characters

January 7th, 2011 by Adrian

Here is a little tool that I have made which can be used to encode and decode strings into URL escape sequences (eg. convert special characters so they are safe to transmit in a query string). I recently also had the need to encode and decode HTML named entity references (eg. ” becomes ”) and after a long hunt around the web I couldn’t find one in AS3. So I have also written a static class called HTMLEntities which has the public methods ‘encode’ and ‘decode’. Hopefully you will find it useful. All the source code is available below.

Download a ZIP of the source code here

NOTE: If you use the HTMLEntities class, you may want to remove the entry for the apostrophe (‘) which encodes it as ' because it is not supported by Internet Explorer. Apostrophes are better off being encoded as '

Here are some useful lists of the HTML Named Entities …

And these are handy conversion tools …

Posted in ActionScript 3.0, Sample Code | 5 Comments »

Test for Capabilities.screenDPI

January 6th, 2011 by Adrian

With all the interest in mobile development there come the issue of dynamically resizing UI elements based on the pixel density of the screen. For example, if a button is set to be 100 pixels wide, it will appear at different physical widths depending on the device being used. This is because your desktop monitor may have a pixel density (DPI or PPI) of 86dpi but you mobile phone may have a pixel density of 326dpi (as is the case with the retina display on the iPhone 4). This may meant that you nicely designed UI is unusable, with items being too small to click on with your finger!

An article regarding this was posted back in Jan 2010 on the Adobe Developer Connection by Christian Cantrell titled ‘Authoring mobile Flash content for multiple screen sizes‘, and more recently (Nov 2010) a whitepaper by Allen Ellison titled ‘Flash sizing Zen: Making Flash fit on mobile devices‘.

In Christian’s article he mentions using the AS3 Capabilities class and the method screenDPI, however as Renaun Erickson pointed out yesterday there is a problem with the returned value from this method when using AIR on devices.

Here is a little test SWF which shows you what Flash thinks your system is displaying (correctly or incorrectly).

Download a ZIP of the FLA source file here

An image of the various sample sizes can be viewed here

Confirming that 86 pixels equals 1 inch on my 19" (1280x1024) monitor

Here are some useful links regarding pixel density, DPI and PPI …

Posted in ActionScript 3.0, AIR, Android, Bug, Flash, iPhone, Mobile, Sample Code | 2 Comments »

QR Code Generator

December 16th, 2010 by Adrian

Over the last couple of days I’ve been messing around with QR Codes and the Google Chart API. Basically I wanted to create a QR code in Flash using Google Charts to do the hard work. However, once I had it sending the data and loading the PNG back in locally, I soon discovered that Google Charts doesn’t have a crossdomain policy file ( This basically meant I couldn’t access the ‘content’ of the Loader object and I couldn’t access the BitmapData of the loaded PNG.

I then remembered reading about using a server-side script to act as a proxy, which would circumvent the security restrictions within Flash. After a lot of digging around on the web I came across a great article on Activetuts+ which had sample PHP code I could use. Success! It was now working online without any security sandbox violations.

Now I had access to the BitmapData of the loaded PNG I could make use of corelib to allow the user to save the resulting image as a PNG or JPEG to their computer. After that I added the ability to print the QR Code on to an A4 sheet directly from Flash. And finally I thought I’d have a go at using AlivePDF to create a PDF file on-the-fly which the user can save to their computer using FileReference (Flash Player 10 and above). I found this blog post by Alex Britez useful when generating the PDF using AlivePDF.

So here is the final SWF and a ZIP file containing all the (FlashDevelop) source is below.

You can view the SWF in it’s own page here.

Download the zipped source here

You can view the Main document class on Snipplr here.

Maybe now I should look at reading a QR Code using AS3.

Posted in ActionScript 3.0, Flash, Sample Code | 7 Comments »

Native Custom Cursors in Flash Player 10.2 using the new MouseCursorData object

December 1st, 2010 by Adrian

Native Custom Cursors

At last, Flash Player 10.2 Beta introduces (among other things) native custom cursors. This is one of those small features that doesn’t get headline news (unlike Stage Video) but is something developers have been requesting for ages, will make our lives a bit easier and will improve the end-user experience.

Thibault Imbert has a post on his blog showing and example of how the new MouseCursorData object and API will work.

Posted in ActionScript 3.0, Adobe, Flash | 2 Comments »

Bug accessing FlashVars when using TLFTextField

November 30th, 2010 by Adrian


I was recently working a project which used both TLFTextFields and FlashVars, and I came across a rather nasty bug. Basically, if you have at least one TLFTextField in your project access to FlashVars will stop working. So I posted the bug on the Adobe Forums – Text Layout Framework section and thankfully Alan Stearns got back to me very quickly with the answer.

The problem is down to the Text Layout Framework Runtime Shared Library preloading.

Take a look at the Forum Thread to see the solution.

My working code can be viewed on Snipplr here.

You can download a ZIP file containing a demo of this bug and workaround here.

To view the FlashVars (when running the SWF in a browser) I am using Arthropod. An AIR based debugger. Download it free from here.

Posted in ActionScript 3.0, Bug | 3 Comments »


November 25th, 2010 by Adrian


Over the last 12 months I’ve been using Snipplr to save code snippets online. It’s a great service for storing, sharing and accessing those bits of code that come in handy. You can also search for other peoples code and mark them as ‘favourites’ and follow people etc.

My snippets can be seen here.

My only criticism would be regarding the search results and the use of ‘tags’. You are able to ‘tag’ your snippets with keywords, but these don’t seem to be taken into account when doing a search. So this limits the results a bit.

Earlier in the year Snipplr was acquired by Envato (Owners of activedentuts+ and many more), which may mean some improvements are on the way.

Posted in ActionScript 3.0, Sample Code | 3 Comments »

Video: Michael Plank’s FDT4 Presentation at Flash Camp Manchester

July 12th, 2010 by Adrian

Michael Plank's FDT4 Presentation at Flash Camp Manchester

Last Thursday I went to Flash Camp Manchester and recorded Michael Plank’s FDT4 presentation.

He does some speed coding and then demonstrates all the shortcuts used.

I have used the pre-release version of Adobe’s Strobe Media Playback to play the video.

Watch it here! (Duration 43 minutes)

Note: It’s progressive download, not streamed.

Posted in ActionScript 3.0, Conferences and Events, Video | No Comments »

Setting the Tab Order of TLFTextFields

July 7th, 2010 by Adrian

I have just spent ages trying to set the tabIndex order of a bunch of TLFTextFields in Flash CS5. With the old Classic TextFields you would have done something along the lines of …

holder_mc.tf1.tabIndex = 1;
holder_mc.tf2.tabIndex = 2;
holder_mc.tf3.tabIndex = 3;
holder_mc.tf4.tabIndex = 4;
holder_mc.tf5.tabIndex = 5;

But with the new TLFTextFields this doesn’t work. You can’t just set the tabIndex property of the TLFTextField directly. When you do, it just doesn’t work.

Then I stumbled across this little bit of info in the docs

tabIndex Documentation

So, for my simple example above to work with TLFTextFields instead of Classic TextFields I ended up writing …

InteractiveObject(holder_mc.tlf1.getChildAt(1)).tabIndex = 1;
InteractiveObject(holder_mc.tlf2.getChildAt(1)).tabIndex = 2;
InteractiveObject(holder_mc.tlf3.getChildAt(1)).tabIndex = 3;
InteractiveObject(holder_mc.tlf4.getChildAt(1)).tabIndex = 4;
InteractiveObject(holder_mc.tlf5.getChildAt(1)).tabIndex = 5;

I hope this helps and that you get it to work quicker than I did!

NOTE 1: I’ve noticed that when the user tabs to a Classic TextField the text is selected, but when you tab to a TLFTextField the caret is positioned at the beginning and no text is automatically selected.

NOTE 2: I’ve also noticed that the selection colour for a Classic TextField is black, but the selection colour for a TLFTextField is light blue. This can look a bit strange when you have a mixture textfields on screen near each other.

Posted in ActionScript 3.0, Sample Code | 1 Comment »

stop(); Action Ignored on Nested Movieclip

December 24th, 2009 by Adrian

Recently I stumbled across this post by Ryan Creighton at Untold Entertainment from back in October 2008 titled ‘stop(); Action Ignored on Nested Movieclip‘. It basically demonstrates how (in AS3) a child movieclip does not stop on the first frame (even though you have put a stop(); action on it) when it’s parent/container is dynamically attached to the stage.

To me this does seem like a bug. Unless I am missing some subtle difference in this area between AS2 and AS3 that I am missing. If so, please can someone explain it to me?

I’ve knocked up a couple of examples to demonstrate …

Firstly, here is the AS2 version that attaches the container movieclip to the stage using the old attachMovie method. Sure enough, the child movieclip does as it is told and stays on frame 1.

And here is the AS3 version that instantiates the Contaner class and adds it to the display list using addChild. As you can see the child movieclip ignores the stop() command on frame 1 and goes to frame 2 instead. Why?

You can download a ZIP file containing the source files for these two examples here.

More discussion about this issue can be found on, but no-one really explains why this is happening. Any ideas?

Posted in ActionScript 3.0, Bug, Sample Code | 3 Comments »

HexoSearch – A Search Engine Dedicated to Actionscript

December 21st, 2009 by Adrian


HexoSearch – The World’s First Search Engine Dedicated to Actionscript

I know this has been around for quite a long time now, but I had kinda forgotten about it. It is a seach engine that is set-up specifically to search ActionScript related sites for your search term. This can be better than just using Google because it helps filter out all the non-actionscript content for you.

You can also add HexoSearch directly into your browser.

Posted in ActionScript 3.0, Tool, Websites | 1 Comment »

GreenSock Tweening Platform has been updated to version 11

October 24th, 2009 by Adrian


The GreenSock Tweening Platform (which includes TweenLite and TweenMax) has recently been updated to version 11. It is still available for AS2 and AS3 and claims to be faster and more capable. There is a huge list of improvements on the GreenSock website (it was great before, even better now) and it has now confirmed to me that it is the best ActionScript tweening engine out there. The website is full of loads of help, examples, documentation, tips, speed tests and faq. I’ve always found the interactive examples on the GreenSock website particularly useful.

Three great new additions to the platform are TweenNano, TimelineLite and TimelineMax. TweenNano is only 1.6k in size and designed to be used where filesize is at a premium (i.e. banner ads). TimelineLite and TimelineMax allow you to build and manage sequences of tweens.

There is a feature comparison on the site and a Getting Started Tweening guide which you may find handy.

Go and check it out, and start using it in your projects.

Great work Jack! Thanks.

Posted in Actionscript 1.0 & 2.0, ActionScript 3.0, Animation, Flash, Flex, Tweening | 2 Comments »

Custom Event Reporting from Flash to Google Analytics

October 8th, 2009 by Adrian


Joseph Labrecque from the University of Denver has posted his session on Flash and Google Analytics that he presented at the FITC Unconference at Adobe MAX 2009. His example uses the gaforflash API which I hadn’t heard of before. It’s pretty interesting stuff and is definatley something that could be useful in the future. His presentation seems fairly clear to understand and thorough.

Check it out here

Posted in ActionScript 3.0, Flash, Presentation | 1 Comment »

ActionScript 3.0 Reference for the Adobe Flash Platform (BETA)

October 7th, 2009 by Adrian

BETA ActionScript 3.0 Reference for the Adobe Flash Platform

Adobe have consolidated all their ActionScript 3.0 help documentation for the Flash Platform in to one central place online. It works using search and filters to show you the information you are looking for.

BETA ActionScript 3.0 Reference for the Adobe Flash Platform

Posted in ActionScript 3.0, Adobe, AIR, Flash, Flex | No Comments »

Printing a PDF document from AIR without displaying it or the control bar (using PDF cross-scripting)

October 6th, 2009 by Adrian

Recently I had a project where I needed to allow the user to print out a PDF document from my AIR application, but I really didn’t need the user to actually view the document first and I didn’t want to display the default PDF control bar. I needed some way to send the PDF file to the printer directly from ActionScript. Enter PDF cross-scripting and Acrobat JavaScript. The following information should help you achieve the same result (note you need to have access to a copy of Adobe Acrobat Pro to add the JavaScript code to your PDF file).

There are several steps required for this to work …

  1. Open the PDF document you want to print in Adobe Acrobat Pro.
  2. Add the JavaScript code to your document and save it.
  3. Create an HTML page that contains a JavaScript function and embed the PDF document.
  4. In your Flash (or Flex) file add a button that prompts the user to print the document.
  5. Add the ActionScript 3.0 code that communicates with the HTML page you created in step 3.
  6. Publish your AIR file (making sure you include the HTML and PDF files).
  7. Test your AIR app.

Here is a copy of the PDF file I am printing in the following example.

Right, let’s explain each of the above steps in more detail.

Step 1

I presume you already have a PDF file prepared which you wish to print. Open this file up in Adobe Acrobat Pro. I’m pretty sure this works in version 7.0 and onwards.

Step 2

Open the ‘JavaScript Functions’ dialog box in Adobe Acrobat Pro by going to ‘Advanced’ > ‘Document Processing’ > ‘Document JavaScripts’.

Acrobat Document JavaScript Menu

Enter ‘myOnMessage’ in to the textfield and click on the ‘Add…’ button.

Acrobat JavaScript Functions

Then enter the following JavaScript code in to the window and click on the ‘OK’ button.

JavaScript Editor

function myOnMessage(aMessage)
      if (aMessage.length==1) {
                  case "Print":
                        //app.alert("Trying to print PDF");
                              bUI: true,
                              bSilent: false,
                              bShrinkToFit: true
                        app.alert("Unknown message: " + aMessage[0]);
            app.alert("Message from hostContainer: \n" + aMessage);

var msgHandlerObject = new Object();
msgHandlerObject.onMessage = myOnMessage;
msgHandlerObject.onError = myOnError;
msgHandlerObject.onDisclose = myOnDisclose;

function myOnDisclose(cURL,cDocumentURL)
      return true;

function myOnError(error, aMessage)

this.hostContainer.messageHandler = msgHandlerObject;

Then remember to re-save your PDF file.

Step 3

Create a blank HTML file and save it next to the PDF file. Then add the following code …

    <title>Load PDF</title>
        function callPdfFunctionFromJavascript(arg)
            pdfObject = document.getElementById("PDFObj");
            try {
            catch (e)
                alert( "Error: \n name = " + + "\n message = " + e.message );
        <object id="PDFObj" data="document.pdf" type="application/pdf" width="800" height="600"/>

Step 4

For this example I’m using Flash CS3. Create a movieclip on stage that acts as a button prompting the user to print the PDF document. Give the button instance the name of ‘button’.

Step 5

In this example I have put all the ActionScript code into the document class. The code looks like this …

    import flash.display.MovieClip;
    import flash.html.HTMLLoader;
    import flash.html.HTMLPDFCapability;

    public class PrintPdfFromAir extends MovieClip
        private var _htmlLoader:HTMLLoader;

        public function PrintPdfFromAir():void
            button.mouseEnabled = false;
            button.alpha = 0.3;
            button.buttonMode = true;
            button.addEventListener(MouseEvent.CLICK, onButtonClick);
            trace("HTMLLoader.pdfCapability: "+HTMLLoader.pdfCapability);
            if (HTMLLoader.pdfCapability == HTMLPDFCapability.STATUS_OK) {
                _htmlLoader = new HTMLLoader();
                _htmlLoader.addEventListener(Event.COMPLETE, onHtmlLoader_COMPLETE);
                var urlRequest:URLRequest = new URLRequest("load_pdf.html");
        private function onHtmlLoader_COMPLETE(event:Event):void
            button.alpha = 1;
            button.mouseEnabled = true;
        private function onButtonClick(event:MouseEvent):void



Basically, we disable to button straight away and add a CLICK event listener. We then check the ‘HTMLLoader.pdfCapability’ property to see if the user has Adobe Reader 8.1 or greater installed on their system. If it equals ‘HTMLPDFCapability.STATUS_OK’ then we can continue. We then create a new instance of the HTMLLoader class, add a listener for the COMPLETE event. We then create an instance of the URLRequest class passing it the name of the HTML file we created in step 3. Next we call the ‘load’ method on our _htmlLoader instance, passing it the urlRequest instance. Then we add the _htmlLoader instance to the stage using addChild.

Normally, when you want to actually display the PDF file on screen, you also need to specify the width and height of the HTMLLoader instance. But in our case we don’t want to actually display it to the user. You may be wondering why we add it to the display list using addChild if we don’t want it to be visible. But I have found that it doesn’t work if you don’t add it to the display list. Not specifying the width and height also means it is not visible (which is what we want on this occasion).

Now we just have the two event handlers to write. The event handler for the HTMLLoader COMPLETE event just makes the button on screen active. We didn’t want the user to be able to click it before the COMPLETE event was fired.

The event handler for the button CLICK event calls the JavaScript function inside the HTML page, which we wrote in step 3.

Step 6

Now you are ready to publish the SWF file and then package it up as an AIR app in the usual way. The important thing to remember is to include the two external files (HTML and PDF) in the AIR Settings dialog box.

Include files

You can create a self-signed certificate for the purposes of testing. I have included my self-signed certificate with the source files (the password is ’1234′) which you can use if you wish, or you could just create a new one.

Step 7

Once you have exported your AIR file it is a good idea to test it on a few different computers to make sure it works properly. Try it on a machine that doesn’t have Adobe Reader installed, or one that has an older version (< 8.1).

Download example AIR app

Download the example AIR file

Click here to download the example AIR file

Download source files

Download ZIP file containing source files

You can download a ZIP file containing my example source files from here.

Useful links

Here are some other blog posts and articles I found useful …

Posted in ActionScript 3.0, AIR, Sample Code | 10 Comments »

Flash Applications on the iPhone!!

October 5th, 2009 by Adrian

It has just been announced at Adobe MAX that Flash Professional CS5 will allow you to set your publish settings to ‘iPhone’. This will compile your movie as a native iPhone app that can be submitted to the Apple AppStore. This is great news. Still no word on Flash within Safari on the iPhone, but to be honest I think being able to create useful standalone applications for the iPhone is better.

Read more info on Adobe Labs

Developer FAQ

Developing for the Apple iPhone using Flash

Adobe TV: Building Applications for iPhone with Flash Pro CS5

Posted in ActionScript 3.0, Flash, iPhone, Mobile | No Comments »

Streaming Video using FMS Gotchya’s

September 17th, 2009 by Adrian

I have just come across a few issues whilst building a video player that plays streaming video from a Flash Media Server.

I thought I had everything set up fine but then when I tested I got the following error message …

ReferenceError: Error #1069: Property onBWDone not found on and there is no default value.

So to resolve this you need to set the client property of the netConnection instance to the object on which callback methods should be invoked. For example …

netConnection.client = this;

and then you need to have an empty public method called onBWDone, like this …

public function onBWDone(...args):void
    trace("onBWDone: "+args);

Sometimes you may get the following error message …

ReferenceError: Error #1069: Property onFCSubscribe not found on XXX and there is no default value.

In which case you’ll need to add …

public function onFCSubscribe(info:Object):void

The same goes for this error message …

ReferenceError: Error #1069: Property close not found on XXX and there is no default value.

In which case you’ll need to add …

public function close(...args):void
    trace("close: "+args);

I then discovered that the netConnection with the server was being closed after 5 minutes of inactivity (e.g. pause the video and leave it for 5 minutes). What you need to do in this case is listen for the ‘NetConnection.Connect.IdleTimeOut’ NetStatusEvent, and gracefully close the netStream yourself. For example …

netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetConnection_NET_STATUS);

private function onNetConnection_NET_STATUS(event:NetStatusEvent):void
    switch ( {
        case "NetConnection.Connect.IdleTimeOut":
        netStream = null;
        // Display a still image or message to the user ro something

Posted in ActionScript 3.0, Sample Code, Video | 1 Comment »

« Previous Entries