GreenSock Tweening Platform has been updated to version 11

October 24th, 2009 by Adrian Parr

GreenSock

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 3.0, Actionscript 1.0 & 2.0, Animation, Flash, Flex, Tweening | 2 Comments »

Custom Event Reporting from Flash to Google Analytics

October 8th, 2009 by Adrian Parr

gaforflash

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 Parr

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
http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/

Posted in AIR, ActionScript 3.0, Adobe, 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 Parr

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) {
            switch(aMessage[0])
            {
                  case "Print":
                        //app.alert("Trying to print PDF");
                        print({
                              bUI: true,
                              bSilent: false,
                              bShrinkToFit: true
                        });
                        break;
                  default:
                        app.alert("Unknown message: " + aMessage[0]);
             }
      }
      else
      {
            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)
{
      app.alert(error);
}

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 …

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

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 …

package
{
    import flash.display.MovieClip;
    import flash.events.MouseEvent;
    import flash.events.Event;
    import flash.html.HTMLLoader;
    import flash.html.HTMLPDFCapability;
    import flash.net.URLRequest;

    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");
                _htmlLoader.load(urlRequest);
                addChild(_htmlLoader);
            }
        }
       
        private function onHtmlLoader_COMPLETE(event:Event):void
        {
            button.alpha = 1;
            button.mouseEnabled = true;
        }
       
        private function onButtonClick(event:MouseEvent):void
        {
            _htmlLoader.window.callPdfFunctionFromJavascript('Print');
        }

    }

}

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 AIR, ActionScript 3.0, Sample Code | 6 Comments »

Flash Applications on the iPhone!!

October 5th, 2009 by Adrian Parr

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
http://labs.adobe.com/technologies/flashcs5/appsfor_iphone/

Developer FAQ
http://labs.adobe.com/wiki/index.php/Applications_for_iPhone:Developer_FAQ

Developing for the Apple iPhone using Flash
http://www.adobe.com/devnet/logged_in/abansod_iphone.html

Adobe TV: Building Applications for iPhone with Flash Pro CS5

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

Flash, Flex, AIR and RIA Conferences 2010

October 1st, 2009 by Adrian Parr

Looking forward to 2010, here is a list of dates to put in your diary. Most of them are Flash Platform related, others are more general but still of interest. I will add to this list as events get announced. If you know of an event that I haven’t mentioned, then post a comment at the bottom and I’ll do my best to add it to the list.

January 2010

February 2010

Macworld 2010
Macworld 2010
February 9th - 13th, 2010
San Francisco, California, US

Mobile World Congress
Mobile World Congress

February 15th - 18th, 2010
Barcelona, Spain

fitc
FITC Amsterdam 2010

February 22nd - 23rd, 2010
Amsterdam, Netherlands

March 2010

CeBIT
CeBIT 2010
March 2nd - 6th, 2010
Hannover, Germany

360|Flex
360|Flex

March 7th - 10th, 2010
San Jose, California, US

Flash Gaming Summit
Flash Gaming Summit 2010
March 8th, 2010
San Francisco, California, US

PushButton Summit 2010
PushButton Summit 2010
March 9th - 10th, 2010
Salt Lake City, Utah, US

SXSW Interactive
SXSW 2010 - Interactive

March 12th - 16th, 2010
Austin, Texas, US

MIX
MIX10

March 15th - 17th, 2010
Las Vegas, Nevada, US

April 2010

NAB Show
NAB Show

April 10th - 15th, 2010
Las Vegas, Nevada, US

FFK10
FFK10

April 13th - 16th, 2010
Cologne, Germany

The Next Web '10
The Next Web Conference 2010

April 21st - 23rd, 2010
Amsterdam, The Netherlands

Fractal'10
Fractal’10

April 23rd - 24th, 2010
Medellin, Colombia

Flash Israel
Flash Israel

April 25th, 2010
Tel Aviv, Israel

FITC
FITC Toronto 2010
April 25th - 27th, 2010
Toronto, Canada

May 2010

Web 2.0 Expo
Web 2.0 Expo
May 3rd - 6th, 2010
San Francisco, California, US

Lift
Lift10

May 5th - 7th, 2010
Geneva, Switzerland

webdu 2010
webdu 2010
May 6th - 7th, 2010
Sydney, Australia

12th flashconference 2010
12th flashconference 2010
May 7th, 2010
Stuttgart, Germany

Adobe Developer Week 2010
Adobe Developer Week 2010
May 10th - 14th, 2010
Online

Multi-Mania
Multi-Mania (2M10)
May 10th - 11th, 2010
Kortrijk, Belgium

Future Everything
FutureEverything (formerly Futuresonic)

May 12th - 15th, 2010
Manchester, UK

Flash and the City
Flash And The City

May 14th - 16th, 2010
New York, US

SOTR 2010
Scotch on the Rocks (SOTR2010)

May 24th - 25th, 2010
Location not announced yet

Web Flash Festival
Web Flash Festival

May 28th - 30th, 2010
Paris, France

June 2010

WWDC10
Apple Worldwide Developers Conference
June 7th - 11th, 2010
San Francisco, California, US

GestureCamp 2010
GestureCamp 2010
June 10th - 12th, 2010
Lille, France

gotoAndSki();
gotoAndSki();
June 11th - 13th, 2010
Galdhøpiggen, Norway

Flashbelt 2010
Flashbelt 2010

June 13th - 16th, 2010
Minneapolis, Minnesota, US

d2w
d2w - Designer/Developer Workflow Conference
June 19th - 20th, 2010
Kansas City, Missouri, US

OFFF
OFFF Paris 2010

June 24th - 26th, 2010
Paris, France

July 2010

Flash at the Lake 10
Flash at the Lake

July 2nd - 3rd, 2010
Zurich, Switzerland

Flash Camp Manchester
Flash Camp Manchester
July 8th, 2010
Manchester, UK

TEDGlobal 2010
TEDGlobal 2010

July 12th - 16th, 2010
Oxford, UK

Siggraph 2010
SIGGRAPH 2010

July 26th - 30th, 2010
Los Angeles, California, US

August 2010

FITC
FITC San Francisco 2010
August 17th - 19th, 2010
San Francisco, California, US

The Adobe Flash Platform Summit 2010
The Adobe Flash Platform Summit 2010
August 25th - 26th, 2010
Bangalore, India

September 2010

Flash Camp Birmingham
Flash Camp Birmingham
September 7th, 2010
Birmingham, UK

IBC2010
IBC2010
September 9th - 13th, 2010
Amsterdam, Netherlands

Flash on the Beach
Flash on the Beach ‘10

September 26th - 29th, 2010
Brighton, UK

October 2010

Being-Digital '10
Being-Digital ‘10
October 7th, 2010
London, UK

Adobe MAX 2010
Adobe MAX 2010

October 24th - 27th, 2010
Los Angeles, California, US

November 2010

Bloom
Bloom
November 18th - 19th, 2010
Cape Town, South Africa

December 2010

Posted in Adobe, Conferences and Events | 3 Comments »