swffit - Smart Flash Resize Script

February 5th, 2010 by Adrian Parr

I remember stumbling across swffit ages ago, but never really gave it much thought at the time. However, a little while ago I put a small Flash site together (www.beauseat.com) for a friend, and it was scaled to fill the browser window. But when you resized the browser down to a small size you lost some of the navigation at the bottom. But today I re-found swffit, and it was just what I needed. It is really easy to use and just works!

Check out the swffit site and Google Code site

Thanks Miller Medeiros

Posted in Flash, HTML | No Comments »

stop(); Action Ignored on Nested Movieclip

December 24th, 2009 by Adrian Parr

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 actionscript.org, but no-one really explains why this is happening. Any ideas?

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

HexoSearch - A Search Engine Dedicated to Actionscript

December 21st, 2009 by Adrian Parr

HexoSearch

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 »

Adobe AIR Runtime Version Checker

December 11th, 2009 by Adrian Parr

Version Checker

Have you ever wondered what version of the Adobe AIR Runtime you have installed on your computer? Well, if you have then you’ve probably found it difficult to find out. Luckily Jason Madsen has built a simple AIR App that will tell you. It does what it says on the tin. Very handy!

BTW, if you want to know what version of the Flash Player you have installed in your browser just visit www.playerversion.com to find out. Thanks Aral.

Posted in AIR, Adobe, Tool | 1 Comment »

Digital Art Exhibition - Decode at Victoria and Albert Museum, London

December 10th, 2009 by Adrian Parr

Decode

Decode: Digital Design Sensations

Victoria and Albert Museum
London, UK
8 December 2009 - 11 April 2010

A new digital art exhibition is on at the V&A in London (in collaboration with onedotzero) called Decode. It is showcasing works from Daniel Brown, Karsten Schmidt (aka Toxi), Aaron Koblin, Golan Levin, Daniel Rozin, Jonathan Harris, Sep Kamvar, Simon Heijdens and Troika. If you are interested in digital art, interactivity, physical computing, installaions, flash, processing, openframeworks or circit bending then I suggest you check it out.

There is also an impressive list of events throughout the duration of the exhibition.

Visit the Decode microsite to find out more information

UPDATE 07/01/10:
Timeout have 2-for-1 tickets

http://www.timeout.com/london/timeout-free-events/tickets/event/id/242

Posted in Conferences and Events, Exhibition, Generative Art, Infographics, Presentation | 2 Comments »

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 | 2 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

Mobile World Congress
Mobile World Congress

February 15th - 18th, 2010
Barcelona, Spain

fitc
FITC Amsterdam 2010

February 22nd - 23rd, 2010
Amsterdam, Netherlands

March 2010

360|Flex
360|Flex

March 7th - 10th, 2010
San Jose, California, 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

May 2010

Lift
Lift10

May 5th - 7th, 2010
Geneva, Switzerland

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

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

Flashbelt 2010
Flashbelt 2010

June 13th - 16th, 2010
Minneapolis, Minnesota, 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

TEDGlobal 2010
TEDGlobal 2010

July 12th - 16th, 2010
Oxford, UK

Siggraph 2010
SIGGRAPH 2010

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

August 2010

September 2010

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

Adobe MAX 2010
Adobe MAX 2010

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

November 2010

December 2010

Posted in Adobe, Conferences and Events | 3 Comments »

Flash, Flex, AIR and RIA Conferences 2009

September 30th, 2009 by Adrian Parr

The 2010 list can be found here …
http://www.adrianparr.com/?p=115

Ok, I know it is a bit late through the year to be posting this, but here is a round-up of conferences and events that relate directly and in-directly to the Flash Platform and digital media in some way. This give you some idea of what happens when and where around the world and what to look out for in 2010. If you want me to add your event then just let me know about it (add a comment at the bottom of this page).

January 2009

Flex Camp Chicago 2009
Flex Camp Chicago

January 22nd - 23rd, 2009
Chicago, Illinois, US

February 2009

FITC
FITC Amsterdam 2009
February 22nd - 24th, 2009
Amsterdam, Netherlands


FOWA - Future Of Web Apps Miami 2009
FOWA - Future Of Web Apps

February 22nd - 24th, 2009
Miami, Florida, US

Flex Camp
Flex Camp Amsterdam

February 25th, 2009
Amsterdam, The Netherlands

Lift
Lift09

February 25th - 27th, 2009
Geneva, Switzerland

Flash Camp London
Flash Camp London

February 26th, 2009
London, UK

March 2009

Flex Camp Ottawa
Flex Camp Ottawa

March 3rd, 2009
Ottawa, Ontario, Canada

TOCA ME
TOCA ME

March 7th, 2009
Munich, Germany

SXSW Interactive
SXSW - Interactive

March 13th - 17th, 2009
Austin, Texas, US

Maker Faire
Maker Faire Newcastle

March 14th - 15th, 2009
Newcastle, UK

MIX09
MIX09

March 18th - 20th, 2009
Las Vegas, Nevada, US

Flash Gaming Summit 2009
Flash Gaming Summit

March 22nd, 2009
San Francisco, California, US

April 2009

The Next Web Conference 09
The Next Web Conference 2009

April 15th - 17th, 2009
Amsterdam, The Netherlands

NAB Show
NAB Show

April 18th - 23rd, 2009
Las Vegas, Nevada, US

FITC
FITC Toronto 2009
April 25th - 28th, 2009
Toronto, Ontario, Canada

FFK09
FFK09

April 27th 30th, 2009
Cologne, Germany

May 2009

flashconference 2009
11th flashconference 2009
May 7th, 2009
Stuttgart, Germany

OFFF
OFFF

May 7th - 9th, 2009
Oeiras, Portugal

Thinking Digital
Thinking Digital

May 13th - 15th, 2009
Gateshead, UK

2M09
Multi-Mania

May 18th - 19th, 2009
Kortrijk, Belgium

360|Flex
360|Flex

May 18th - 20th, 2009
Indianapolis, Indiana, US

Flash On Tap
Flash On Tap

May 28th - 30th, 2009
Boston, Massachusetts, US

FlashCamp
Flash Camp San Francisco

May 29th, 2009
San Francisco, California, US

BarCampLeeds
BarCampLeeds

May 30th - 31st, 2009
Leeds, UK

Maker Faire
Maker Faire Bay Area

May 30th - 31st, 2009
San Francisco, California, US

June 2009

flashbelt
Flashbelt

June 7th - 10th, 2009
Minneapolis, Minnesota, US

Warsaw Flash Camp 2009
Flash Camp Warsaw

June 9th, 2009
Warsaw, Poland

REMIX09 Australia
REMIX09 Australia
June 11th, 2009
Sydney, Australia

Flash Camp
Flash Camp Birmingham

June 16th, 2009
Birmingham, UK

Digital Media Conference
Digital Media Conference East

June 25th 2009
Washington, D.C., US

fotl09
Flash at the Lake

June 26th - 27th, 2009
Zurich, Switzerland

July 2009

TED Global 2009
TEDGlobal

July 21st - 24th, 2009
Oxford, UK

August 2009

SIGGRAPH2009
SIGGRAPH

August 3rd - 7th, 2009
New Orleans, Louisiana, US

cfunited
CFUnited

August 12th - 15th, 2009
Leesburg, Virginia, US

Flash camp Atlanta
Flash Camp Atlanta

August 28th, 2009
Atlanta, Georgia, US

September 2009

ARS Electronica
ARS Electronica

September 3rd - 8th, 2009
Linz, Austria

dConstruct 2009
dConstruct

September 4th, 2009
Brighton, UK

Flex Camp
Flex Camp Rimini

September 5th, 2009
Rimini, Italy

BarCamp Brighton 4
BarCampBrighton

September 5th - 6th, 2009
Brighton, UK

onedotzero
onedotzero - adventures in motion

September 9th - 13th, 2009
London, UK

IBC2009
IBC2009
September 10th - 14th, 2009
Amsterdam, Netherlands

Flash Camp St Louis
Flash Camp St. Louis

September 11th, 2009
St. Louis, Missouri, US

FITC
FITC Mobile 2009
September 13th - 14th, 2009
Toronto, Ontario, Canada

The Actionscript Conference '09
The Actionscript Conference

September 14th - 15th, 2009
Singapore

Lift
Lift Asia 09

September 17th - 18th, 2009
Jeju, Korea

Flash Platform Code Camp Wellington
Flash Platform Code Camp Wellington

September 19th, 2009
Wellington, New Zealand

Flash on the Beach
Flash on the Beach

September 20th - 23rd, 2009
Brighton, UK

London Digital Week
London Digital Week

September 21st - 27th, 2009
London, UK

i-design 09
i-Design 09
September 24th, 2009
London, UK

FOWA - Future Of Web Apps
FOWA - Future Of Web Apps

September 30th - October 2nd, 2009
London, UK

October 2009

FITC
LAFlashapoloozastock IV

October 3rd, 2009
Venice Beach, California, US

FITC
FITC Unconference @ MAX

October 4th - 7th, 2009
Los Angeles, California, US

360|MAX
360|MAX Unconference

October 4th - 7th, 2009
Los Angeles, California, US

Adobe MAX
Adobe MAX

October 4th - 7th, 2009
Los Angeles, California, US

Flashpitt09
Flashpitt

October 15th - 16th, 2009
Pittsburgh, Pennsylvania, US

Flash Camp Cairo 09
Flash Camp Egypt

October 17th, 2009
New Cairo, Egypt

Play
PLAY :: The Berkeley Digital Media Conference

October 17th, 2009
Berkeley, California, US

FITC
FITC Edmonton

October 17th - 18th, 2009
Edmonton, Alberta, Canada

SotR09
Scotch on the Road

October 19th - 29th, 2009
Munich, Germany
Zurich, Switzerland
Milan, Italy
Amsterdam, The Netherlands
Brussels, Belgium
London, UK

Digital Media Conference West
Digital Media Conference West

October 28th, 2009
San Francisco, California, US

Playful
Playful

October 30th, 2009
London, UK

November 2009

View
VIEW Conference

November 4th - 7th, 2009
Turin, Italy

Flash Camp Philadelphia
Flash Camp Philadelphia

November 7th, 2009
Philadelphia, Pennsylvania, US

Latin Flash Tour
Latin Flash Tour

November 7th - 18th, 2009
Santiago, Chile
Buenos Aires, Argentina
Lima, Peru
Bogotá, Colombia
San Jose, Costa Rica
Mexico City, Mexico

RIA Unleashed : Boston
RIA Unleashed : Boston

November 13th, 2009
Boston, Massachusetts, US

FOWD
FOWD - Future Of Web Design

November 16th - 17th, 2009
New York, US

Flex Camp Wall Street
Flex Camp Wall Street
November 16th - 17th, 2009
New York, US

CaT
CaT London
November 19th, 2009
London, UK

FITC
FITC Tokyo

November 28th, 2009
Tokyo, Japan

December 2009

RIAdventure 360
RIAdventure 360

December 6th - 13th, 2009
Depart from New Orleans, Louisiana, US then cruise around the Caribbean

Posted in Adobe, Conferences and Events | 3 Comments »

Flash on the Beach 09 - See you there!

September 20th, 2009 by Adrian Parr

Flash on the Beach 09

Yay! It’s that time of the year again to head down to Brighton for Flash on the Beach. I’m looking forward to being inspired, educated and meeting up with fellow Flashers.

See you there!

Posted in Conferences and Events | No Comments »

Streaming Video using FMS Gotchya’s

September 17th, 2009 by Adrian Parr

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 flash.net.NetConnection 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
{
    trace("onFCSubscribe");
}

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 …

import flash.events.NetStatusEvent;
netConnection.addEventListener(NetStatusEvent.NET_STATUS, onNetConnection_NET_STATUS);

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

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

Flash Player dispatches KEY_DOWN event when entering FullScreen mode (Bug)

September 17th, 2009 by Adrian Parr

Have just built a video player that allowed the user to switch to FullScreen mode and toggle the play/pause state using the SPACE key on their keyboard. However, I found that everytime the Flash movie entered FullScreen mode the playing video would pause and visa-versa.

I then discovered that the Flash Player was dispatching a KEY_DOWN event when entering FullScreen mode. More specifically, the keyCode == 32, which corresponds to the spacebar on your keyboard.

My Flash Player version is WIN 10,0,32,18

See an example of it here …

Here is code for the above demo movie …

package
{
    import flash.display.MovieClip;
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.text.TextField;
    import flash.display.StageDisplayState;
   
    import fl.controls.Button;

    public class FullscreenSpaceBug extends MovieClip
    {
       
        public var tf:TextField;
        public var clearBtn:Button;
        public var goBtn:Button;
        public var exitBtn:Button;

        public function FullscreenSpaceBug():void
        {
            trace("FullscreenSpaceBug()");
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
            clearBtn.addEventListener(MouseEvent.CLICK, onClearBtn_CLICK);
            clearBtn.focusEnabled = false;
            clearBtn.useHandCursor = true;
            goBtn.addEventListener(MouseEvent.CLICK, onGoBtn_CLICK);
            goBtn.useHandCursor = true
            exitBtn.addEventListener(MouseEvent.CLICK, onExitBtn_CLICK);
            exitBtn.useHandCursor = true;   
            tf.text = "";
        }
       
        private function onGoBtn_CLICK(event:MouseEvent):void
        {
            stage.displayState = StageDisplayState.FULL_SCREEN;
        }
       
        private function onExitBtn_CLICK(event:MouseEvent):void
        {
            stage.displayState = StageDisplayState.NORMAL;
        }
       
        private function onStage_KEY_DOWN(event:KeyboardEvent):void
        {
            if (event.keyCode == 32) {
                tf.appendText("event.keyCode = "+event.keyCode+"   (SPACE)\n");
            } else {
                tf.appendText("event.keyCode = "+event.keyCode+"\n");
            }
            tf.scrollV = tf.maxScrollV;
        }
       
        private function onClearBtn_CLICK(event:MouseEvent):void
        {
            tf.text = "";
        }

    }

}

I managed to find an entry for this bug in the Adobe Flash Player Bug and Issue Management System (JIRA Database). FP-814: Flash Player dispatches KEY_DOWN event when entering FullScreen Mode

I also found a very similar blog post by TyZ which was posted on 25th August 2009 titled ‘Flash bug when enter fullscreen keyboard events fired - Workaround‘.

The workaround is to temporarily remove the KEY_DOWN event listener, and add it again with a slight delay once the FULL_SCREEN event has been dispatched. You could create the delay by using either a Timer, an ENTER_FRAME event or the setTimeout method. In TyZ’s example he used an ENTER_FRAME event, in my example below I use an instance of the Timer class.

WORKAROUND EXAMPLE

Here is the code for the workaround …

package
{
    import flash.display.MovieClip;
    import flash.display.StageDisplayState;
    import flash.ui.Keyboard;
    import flash.events.KeyboardEvent;
    import flash.events.MouseEvent;
    import flash.events.FullScreenEvent;
    import flash.text.TextField;
    import flash.events.TimerEvent;
    import flash.utils.Timer;

   
    import fl.controls.Button;

    public class FullscreenSpaceWorkaround extends MovieClip
    {
       
        public var tf:TextField;
        public var clearBtn:Button;
        public var goBtn:Button;
        public var exitBtn:Button;

        public function FullscreenSpaceWorkaround():void
        {
            trace("FullscreenSpaceBug()");
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
            stage.addEventListener(FullScreenEvent.FULL_SCREEN, onStage_FULL_SCREEN);
            clearBtn.addEventListener(MouseEvent.CLICK, onClearBtn_CLICK);
            clearBtn.focusEnabled = false;
            clearBtn.useHandCursor = true;
            goBtn.addEventListener(MouseEvent.CLICK, onGoBtn_CLICK);
            goBtn.useHandCursor = true
            exitBtn.addEventListener(MouseEvent.CLICK, onExitBtn_CLICK);
            exitBtn.useHandCursor = true;   
            tf.text = "";
        }
       
        private function onGoBtn_CLICK(event:MouseEvent):void
        {
            stage.removeEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
            stage.displayState = StageDisplayState.FULL_SCREEN;
        }
       
        private function onExitBtn_CLICK(event:MouseEvent):void
        {
            stage.displayState = StageDisplayState.NORMAL;
        }
       
        private function onStage_FULL_SCREEN(event:FullScreenEvent):void
        {
            if (event.fullScreen) {
                var timer:Timer = new Timer(200, 1);
             timer.addEventListener(TimerEvent.TIMER, onTimer);
             timer.start();

            }
        }
       
        private function onTimer(event:TimerEvent):void
        {
            stage.addEventListener(KeyboardEvent.KEY_DOWN, onStage_KEY_DOWN);
        }
       
        private function onStage_KEY_DOWN(event:KeyboardEvent):void
        {
            if (event.keyCode == 32) {
                tf.appendText("event.keyCode = "+event.keyCode+"   (SPACE)\n");
            } else {
                tf.appendText("event.keyCode = "+event.keyCode+"\n");
            }
            tf.scrollV = tf.maxScrollV;
        }
       
        private function onClearBtn_CLICK(event:MouseEvent):void
        {
            tf.text = "";
        }

    }

}

Download the source files for the workaround here

Posted in ActionScript 3.0, Bug | 9 Comments »

Learning ActionScript 3.0 on the Move With Your iPhone

August 14th, 2009 by Adrian Parr

Lost ActionScript Weekend

A couple of months ago I purchased Colin Moock’s Lost ActionScript 3.0 Weekend DVDs (Course 1 and Course 2). Basically, these two O’Reilly training DVDs were filmed over a weekend with Colin Moock, Hoss Gifford and James Paterson. They cover as lot of the material featured in Colin’s Essential ActionScript 3.0 book, but it is well presented in an informal and easy to digest manner. The training is broken up in to small, easily digestible chunks, which make it great to watch when you have a spare ten minutes here and there.

The video files provided on the DVDs are regular FLV files, and can be played back through the provided Flash Projector. Or, as I have done, convert the FLV files to MP4 (I used the now sadly discontinued VisualHub) and copy them across to your iPhone. This is a great way to improve your ActionScript 3.0 knowledge whilst on the bus or train.

Learning ActionScript 3.0

I also purchased the electronic version of Learning ActionScript 3.0 by Rich Shupe and Zevan Rosser which comes in three formats (Mobi, PDF and ePub). The ePub version can be viewed on your iPhone using the free Stanza App (if you have a Kindle then the Mobi format will work well). I was pleasantly surprised how clear the text is and how easy it is to read on the small screen. Stanza works well and allows you to navigate around the sections, change the font size and colours etc.

ActionScript 3.0 API Reference

Finally, if you haven’t already downloaded it, go and get Mike Chambers’ ActionScript 3.0 API Reference iPhone App. This puts the entire documentation for AS3 in your pocket. My only gripe is that the length of the line of text is quite long which makes the font become very small and difficult to read. It is a shame the text doesn’t wrap when you zoom in.

Posted in Uncategorized | 1 Comment »

Make your cursor always point to the middle of the screen

August 14th, 2009 by Adrian Parr

Yesterday I was taking a look at Balsamiq Mockups and liked the way that the mouse always pointed to the centre of the screen when in fullscreen mode. So I thought I’d quickly knock something to together that did this, and share it here.

It’s pretty simple stuff, but handy to have available to copy-and-paste, if you need something similar.

The code is all in the document class …

package
{
    import flash.display.MovieClip;
    import flash.events.Event;
    import flash.events.MouseEvent;
    import flash.ui.Mouse;

    public class Main extends MovieClip
    {
       
        private var mouseIsOverStage:Boolean;
        private var arrow:Arrow;

        public function Main():void
        {
            arrow = new Arrow();
            Mouse.hide();
            stage.addEventListener(Event.MOUSE_LEAVE, onStage_MOUSE_LEAVE);
            stage.addEventListener(MouseEvent.MOUSE_MOVE, onStage_MOUSE_MOVE);
        }
       
        private function onStage_MOUSE_LEAVE(event:Event):void
        {
            mouseIsOverStage = false;
            removeChild(arrow);
        }
       
        private function onStage_MOUSE_MOVE(event:MouseEvent):void
        {
            if (!mouseIsOverStage) {
                mouseIsOverStage = true;
                onStage_MOUSE_ENTER();
            }
            arrow.x = stage.mouseX;
            arrow.y = stage.mouseY;
            var dx:Number = arrow.x - stage.stageWidth/2;
            var dy:Number = arrow.y - stage.stageHeight/2;
            var radians:Number = Math.atan2(dy, dx);
            arrow.rotation = radians * 180/Math.PI;
            event.updateAfterEvent();
        }
       
        private function onStage_MOUSE_ENTER():void
        {
            arrow.x = stage.mouseX;
            arrow.y = stage.mouseY;
            addChild(arrow);
        }
       
    }

}

Download the source files here

Posted in ActionScript 3.0, Sample Code | No Comments »

Understanding Games

August 13th, 2009 by Adrian Parr

Understanding Games

I have just come across four great animations called Understanding Games. Each episode (1, 2, 3 and 4) looks at a different aspect of game design and is done in a simple, engaging and interactive way. I love the retro styling and the way the information is presented.

Whilst you are there (http://www.pixelate.de), check out the game called Mr Bounce.

Posted in Animation, Game, Infographics, Theory, Tutorials | No Comments »

Box2D Video Tutorials

August 12th, 2009 by Adrian Parr

Box2DFlashAS3

I have just come across some great video tutorials for the Box2D physics engine in Flash AS3. They have been recorded by a chap called Todd Kerpelman. The website address is …

http://www.kerp.net/box2d/

He has over 70 screencasts on there going through the process of using Box2DFlashAS3.

I also found a few useful links over on a blog post by Matthijs Kamstra.

Posted in ActionScript 3.0, Tutorials | No Comments »

Launched: Open Source Media Framework Blog

August 7th, 2009 by Adrian Parr

Open Source Media Framework Blog

A blog focussing on the Open Source Media Framework has just been launched. Product Manager Sumner Paine has posted a couple of blog posts. I’d recommend adding their RSS feed to your aggregator of choice.

Find out more …

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

« Previous Entries