AS3

Passing data to AS classes at compile time

It's useful to be able to pass data to Flash code at compile-time rather than at runtime. So during your build process you can in some way configure the build - the obvious reason would be to turn on or off some debugging or instrumentation, but you could also configure features, pass in build numbers, set in initial languages etc. all depending on some build parameters or other.

Using a template?

The obvious way would be to in some way template the .as file you're compiling, like so:

package {
public class MyConfigClass
{

Brutalising the Flex Compiler: Tighter Control of Resource Files and CSS

Recently I've been reworking our in-house build process and dealing with a specific requirement; notably that graphical and text assets (and layouts) be separated out in such a way that they are combined - dynamically - at compile time or at runtime.

I went back and forth through a couple of different ways of doing it, and then threw out a lot of code, realising that I could hijack some of the Flex SDK's features to do it for me.

Scribble!

Not so much a hint or tip - more an experiment.

At Flash on the Beach this year, James Paterson was one of the inspirational speakers. During his talk he showed off a novel 3D sketching tool (well, novel to me, anyway) which let you sketch a pen line on a 2D plane, then rotate, and sketch again, adding another plane to your scribble.

I believe it was written in C or C++ (from memory).

ActionManager

I was asked recently - well, okay, not that recently, I've been busy - about our ActionManager system and how it works. I said that if I had time I'd open-source it; so here's a (cut-down) version of it.

Our system was developed in AS2, and has now been ported to AS3; it's been around for a while now and has taken most of what we've thrown at it.

At its root, it's a simple concept, and it's not far removed from many tweening engines that exist out there.

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.

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>

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.

Checking constructor compatibility

This originally appeared on my blog back in October 2007.

I needed to compare two Class objects in AS3 today, to work out if one was a descendant from another - note neither of these are instances (which you could just compare with a simple if (a is SomeClass)), they are both uninstantiated.

This is what I came up with, after a bit of fiddling.

public static function isClassCompatibleWith(test:Class,desired:Class):Boolean
{

Syndicate content