Useful code snippets and bits and pieces from the developers at Awen.

Welcome to the Awen Code website!

We've put together this site as a prelude to Awen starting to offer tools to Flash developers. More details on those tools will be featured on this site in the near future; in the meantime, feel free to have a browse through Awen's hints and tips for working with Actionscript, Flash and Flex.

Running AS2 Content in AS3: Beware!

It is perfectly possible to run an AS2 movie within an AS3 Flash application.

However, my advice would be - don't.

Here are a handful of the problems we've encountered when running any AS2 movie of any complexity within AS3:

Making a MovieClip act like a Button

In AS3 (and actually using a similar method in AS2) you can make a MovieClip act just like a button like so:

Give your MovieClip 3 frames, labelled _up, _over and _down.

Create your MovieClip:

var clip:MovieClip=new MyClip();
clip.buttonMode=true;
// Need this, because otherwise any interactive children will break the button behaviour
clip.mouseChildren=false;
clip.stop();

Now when you attach your clip to the display tree, it'll show up, over and down states as appropriate.

Version Cue Server CS3 with external drives under OSX

We've taken a decision at Awen to use Adobe's Version Cue as the version control system for projects. Sadly, being a proprietary system, it won't play ball with our existing Linux server, insisting instead on Windows or OSX as a platform.

We decided that OSX's Unix pedigree was worth pursuing, and picked up a Mac Mini with a pair of 500Gb external hard drives to ensure we have disk space for all of our projects for a while longer. I decided to set one of these drives solely as the repository for Version Cue.

Smoothing loaded bitmaps in AS2

In Actionscript 2, there is a niggling annoyance with scaling bitmaps images (i.e. JPEG, PNG or GIF images). If such an image is in your Flash movie's library, you can tick the "Allow Smoothing" option; this means that when the image is scaled (up or down) the Flash player does its best to eliminate the jagged, "bitty" look of the resized image - the results are normally pretty good.

However, if you're loading in an image directly - for example, using MovieClipLoader - there is no way to turn on smoothing for that image.

Setting AIR window size whilst ignoring chrome

You specify the size of the initial window of your AIR application within an application descriptor file, like below:

<?xml version="1.0"?>
<application xmlns="http://ns.adobe.com/air/application/1.0">
    :
    :
    <initialWindow>
	<title>MyWindow</title>
        <content>main.swf</content>
        <width>800</width>
        <height>600</height>
    </initialWindow>
    :
</application>

NSIS script for faking a single executable

We've occasionally come across situations where we want to pack up our Flash projects as single executable files - not installers! - that can be run on the desktop without needing to be installed. This is like just creating and running a Flash projector.exe - however, our projects generally consist of more than one file, and packing them up as a single projector is impossible. We've also hit this when using the Flash wrapper SWHX, which depends on a lot of external files.

Is my file up to date? Ant and Flex compile dependencies

At Awen we use the Flex SDK to compile AS3 code and MXML from within Ant.

I'm currently in the process of updating our build system. Obviously, like all good build systems, it would be nice if a build only rebuilt things which have changed. Or rather, where the source code that affects a build product has changed. This makes a build process so much faster.

Creating Windows shortcuts in AIR

So, while evaluating AIR as a potential wrapper for our latest project, our only major issue is that AIR doesn't give you the option of creating more than one icon in the Windows Start Menu. Our products tend to come with associated config applications or support documents, and historically we've always put links to them in the Start Menu.

So I started to look into how to create Windows shortcuts using AIR.

This should have been easy, but thanks to Microsoft's proprietary binary file format, it really wasn't.

Come back Delegate, all is forgiven

This originally appeared on my blog back in April 2007. I've cleaned it up a bit and put it here.

The Problem

When I started to play with AS3, one of the things I jumped up and down about was the fact that we could finally junk the ubiquitous Delegate that appeared scattered throughout all our code - just in there to make sure that functions had the right context.

Syndicate content