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 »

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 actionscript.org, 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

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 »

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

http://help.adobe.com/en_US/FlashPlatform/beta/reference/actionscript/3/

Posted in ActionScript 3.0, Adobe, AIR, Flash, Flex | No 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

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, iPhone, Mobile | No Comments »

Box2D Video Tutorials

August 12th, 2009 by Adrian

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 »

AS3 Code Libraries (APIs)

August 19th, 2008 by Adrian

Here is a round up of some of the most popular ActionScript 3.0 (AS3) libraries out there to use.

Let me know if I have missed an important one off.

NOTE: This list was originally for my personal use (that I thought I would share), it is not intended to compete with or replace the list maintained by OSFlash or RIAForge.

Update 29/10/08: Ted Patrick has put together a list of ActionScript Cloud/Service APIs that he going to highlight during his Adobe MAX 2008 keynote presentation.

Update 28/11/08: I have just come across the Actionscript Classes website. A very handy resource.

Update 11/01/09: Rich Tretola has a small list of AS3 Libs on his blog EverythingFlex.

Update 12/01/09: The Flashchemist has compiled a similar list on his blog.

Update 27/02/09: Check out Spark Project which includes the FLARToolkit for Augmented Reality

Update 11/08/09: I just stumbled across this (old) list of projects.

Update 19/12/09: Sean “theflexguy” Moore has just written a blog entry called ‘List of 34 More ActionScript 3.0 APIs‘. This is a follow-up to his original post ‘List of 22 ActionScript 3.0 API’s‘.

Update 22/12/09: “30+ ‘Must Try’ Open Source Actionscript 3 Libraries” and “30 MORE Awesome Open Source AS3 Libraries

Update 28/01/10: “30 Classes AS3 bem úteis!”

Update 29/01/10: “15 Awesome ActionScript 3 Frameworks To Inspire Your Next Project”

Update 24/02/10: Emanuele Feronato has a good list of Isometric Engines on his blog

Update 19/03/10: Tom Krcha has posted a list of Flash Gaming Engines, plus a few others that were new to me.

Update 09/07/10: FluxDb has a huge list of AS3 Libraries.

Update 15/04/12: Exagone has a list of libraries

Update 16/04/12: 68 Small but Useful Open Source ActionScript Libraries (misc) help Flex/Flash Developers Improve Work Efficiency

Update 17/04/12: List of ActionScript 3.0 APIs

3D Engines

3D Game Engines

2D Engines (utilising the GPU using Stage3D)

2D Game Engines

Isometric Engines

3D Animation Framework

3D Physics Engines

Augmented Reality

Animation Tweening Engines

2D Physics Engines

Security

Audio Libraries

Particle Systems

Data Visualization

Loading Kits

OOP Frameworks

Website Frameworks

Debug / Stats / Trace / Output Panels

Other APIs and libraries

Posted in ActionScript 3.0, AIR, Augmented Reality, Flash, Flex, Papervision 3D, Tweening | 123 Comments »

Setting the stage quality in AS3

March 27th, 2008 by Adrian

This is how you set the stage quality using ActionScript 3.0

Old AS1 & AS2 code was …

_quality = "LOW";

New AS3 code is …

stage.quality = StageQuality.LOW;

The setting options are BEST, HIGH, MEDIUM & LOW.

If you are using this inside a class, you will also have to import the ‘StageQuality’ class from within the ‘flash.display’ package…

import flash.display.StageQuality;

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

Setting framerate and stage size in AS3 project using Flex

March 10th, 2008 by Adrian

UPDATE 29/07/2010: Flash CS4 and CS5 now support this metadata, and will override the stage properties that are set in the IDE.

If you are creating an AS3 only project in Flex then at some point you will want to set the framerate, stage size, and stage colour. This is not obvious to find and can be done in one of two ways.

The first method is by providing this information as compiler arguments in the Flex IDE. Go to Project > Properties > ActionScript Compiler. And in the ‘Additional compiler arguments:’ textfield you could enter the following …

-default-frame-rate 25 -default-background-color #FFFFFF
-default-size 800 600

The second method is by putting this information in to your main AS3 class as metadata. For example …

package {
     import flash.display.Sprite;

     [SWF(width='800',height='600',backgroundColor='#ffffff',frameRate='25')]

     public class Test extends Sprite {
          public function Test() {

          }
     }
}

Make sure you put the SWF Metadata AFTER any import statements.

Here are a couple of other blog entries on the subject …

Posted in ActionScript 3.0, Flex | 2 Comments »

Detecting key presses in AS3

February 25th, 2008 by Adrian

Keyboard

In ActionScript 3 you can detect key presses on the keyboard using the Stage class. I discovered that the Stage object is not globally accessible. You need to access it through the stage property of a DisplayObject instance. So from within a Class you can check which keys are being pressed using the following code.

package {
    import flash.events.KeyboardEvent;
    import flash.display.MovieClip;

    public class KeyboardTest extends MovieClip {

        private var base:MovieClip;

        public function KeyboardTest($base:MovieClip):void {
            trace("KeyboardTest constructor is being run");
            base=$base;
            base.stage.addEventListener(KeyboardEvent.KEY_DOWN,keyboardListener);
        }

        private function keyboardListener(event:KeyboardEvent):void {
            trace("event.keyCode: " + event.keyCode);
        }
    }
}

Posted in ActionScript 3.0, Sample Code | No Comments »

Colin Moock’s ActionScript 3.0: From The Ground Up Tour

January 28th, 2008 by Adrian

Colin Moock

Hooray! I managed to get a ticket to the Colin Moock ActionScript 3.0 training day being ran by Adobe. I’ll be attending the London event on Monday 3rd March 2008. The event is being held at Vinopolis, the famous wine tasting venue (map here). I hope we get some free wine to help us get our heads around the nitty-gritty of AS3. See you there, if you are going as well.

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