Actionscript 3

Upload to YouTube from Flash

08-26-2009 Update: YouTube recently made an undocumented change to their API. Now, the upload URL you get in step 6 will be at the domain "". The crossdomain.xml file at this domain prevents flash from uploading to it. More


So I've been getting some questions about text links in as3 lately, so I'll blog about it.

If you want just a simple text link from dynamic text in as3, here's your solution. This is only good for clicks, not for mouseovers, but i do have another solution for that.

First set the text:

textFieldName.html = "I want either a Large pizza or a Extra Large pizza";

Next add the TextEvent Listener with the event Link and the method: More

textFieldName.addEventListener(TextEvent.LINK, textLinkHandler);

function textLinkHandler(e:TextEvent):void {
    switch(e.text) {
        case "large":
            trace("Make it a LARGE");

Shortcut Manager - an AS3 class to easily manage keyboard shortcuts in Flash

ShortcutManager is an AS3 class to make it easier to add and manage keyboard shortcuts in a flash movie.

Documentation is at  The docs aren't very filled out at this point, but hopefully the naming scheme gives you enough information.

Shortcut Manager provides the following benefits: More

  • Simplifies the creation of shortcuts, especially multi-key shortcuts
  • Simplifies adding/changing shortcuts at run time
  • Lets you name and organize shortcuts
  • Lets you check if a given shortcut already exists, or if a function has a shortcut associated with it

Change font embedding for all textFields in an FLA

So your client calls you up and says, "Hey, remember that flash movie you made for us 4 months ago? We want it to support Japanese text" Oh great - now you've got to go through every textField in the movie and change the font embedding settings.

Psssh, forget that. Too tedious. Let's use JSFL instead. More

Using Flash content as a Flex component

The user interface components in the flex SDK are pretty nice, but not the easiest thing to customize.  Skinning only goes so far.  When you need a ComboBox, or a DataGrid - or some other generic data display component - they're great, but a whole app built just out of Flex components ain't gonna cut it.  I mean honestly, what's the point of using the Flash platform if you can't customize the bejeezus out of your visual interface? Sometimes, you need the extreme flexibility that only Flash provides. More

Keyboard shortcuts in a swf - Don't use Ctrl.

If your flash movie is fairly complex, or needs to be keyboard accesible, you may want to implement some keyboard shortcuts to simplify things for your user. Using a combination of the "Ctrl" key (or Cmd, if you're mac-inclined) and a letter key might seem like a natural choice. However, there are a couple reasons why this is bad:

1. Flash doesn't take keyboard priority in all browsers.
In Windows (XP), Chrome, Opera, and FireFox allow Flash Player to intercept the keyboard input, so if you make a "Ctrl+t" shorcut in your movie, pressing that key combination won't open a new tab anymore (as long as the flash movie has focus) - it'll do whatever your flash movie says "Ctrl+t" should do. More is AIR only?

The other day I came across a bug with AS3's function. If there was a right parentheses ")" in the string to be searched, the function would always return -1, even if the pattern I was searching for did exist within that string. As you can see if you test this code: More


Multiline strings in MMExecute() - beware the newline "\n" character!

When sending JSFL from a swf to Flash using MMExecute(), occurrences of the newline character ("\n") will cause the following error: More

unterminated string literal

Giving JAWS users notifications from flash

When a JAWS user "clicks" on a link in an HTML page, JAWS gives auditory notifications that a new page is loading, and starts reading the page once it is complete. In flash however, JAWS only sees what you go out of your way to wave in front of its face. If a JAWS user clicks on a button in a flash movie that changes all content on screen, all JAWS (and more importantly, your viewer) knows is that they clicked a button. There will be nothing to tell them that clicking that button had any effect.

To give notifications to JAWS users, I've been toying with the following method:

1.add a movieClip to the stage,

2.assign it an AccessibilityProperties with "name" set to the message I want the user to hear

3. set stage.focus to the movieClip I created. More

Don't rely on ProgressEvent.PROGRESS events

When using a preloader on the first frame of your movie, don't rely strictly on the ProgressEvent.PROGRESS event to determine if your movie has fully loaded. For instance if you have something like this on your first frame: More


this.loaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler);

function progressHandler(e:ProgressEvent):void {
    loader.textBox.text = e.bytesLoaded/e.bytesTotal*100+"%"
    if(e.bytesLoaded == e.bytesTotal) {