Skip to content
February 1, 2011 / Rob Fox

Calling a subclass’ method from superclass (kind of) in AS3

Note: This is a strange hack, I wasn’t thinking straight when I wrote this. You shouldn’t use this. Maybe it can give you some ideas though :D.

To call a subclass’ method from superclass in AS3 you can declare a variable type function and change it runtime like this:


class Animal
    var foo:Function = function():void {trace("Animal"); }


class Cat extends Animal
    function Cat()
    { = function():void {trace("Cat"); };

October 16, 2010 / Rob Fox

My simple Java XML parsing class

xml imageImage from

When in AS3 parsing XML is easy as pie, then in Java there is no default XML parsing class. There are tons of (better) classes out there, but I decided to code my own.

The class lets you create a new XML file and pass it a string of xml. Then it simply lets you parse it using it’s get() method. It knows how to get the content from normal tags such as <entry>content<entry> as well as tags with parameters, such as <entry type=”html”>content<entry>.

How get() works:

You give it 2 parameters:
String tag – tag name
int position – the position of the tag (0 for first, 1 for second and so on). Also a thing to notice is that if we pass the position value of -1 the function will return the amount of tags (opening and closing count as one) in the XML file.


//create a new XML object and pass it the xml String
XML xml = new XML(xmlString);
//print out the content of the 6th title tag
System.out.println(xml.get(“title”, 5));

And the class: Read more…

September 26, 2010 / Rob Fox

Simplifying mouse movement

So, I am working on this game where I need to check if the player is dragging the mouse up/down/left/right. To make this work nicely we have to judge the axis of movement first. But deciding the axis isn’t that simple because the player’s mouse will be shaking. That why we need to simplify the mouse movement (because wordpress wont let me embed flash files you have to try it HERE).

And the code:

Read more…

August 30, 2010 / Rob Fox

Fixing console in FlashPunk using Flex 4 (or greater).

Ok, so if your using Flex 4 or greater and trying to get the FlashPunk console to work you have probably noticed that there’s no text showing.

This is the same bug I mentioned in my previous post.

At ../net/flashpunk/debug/ there is a file Open is and scroll down to line 870 where lies:

[Embed(source = '../graphics/04B_03__.TTF', fontFamily = 'console')] private const FONT_SMALL:Class;

Replace this with:

[Embed(source = '../graphics/04B_03__.TTF', embedAsCFF="false", fontFamily = 'console')] private const FONT_SMALL:Class;
August 28, 2010 / Rob Fox

Displaying text with FlashPunk using Flex 4 (or greater).

When normally embedding a fond you would write:

[Embed(source = "assets/nokiafc22.ttf", fontFamily = "nokiafc22")]private const myFont:Class;

But when using Flex 4 or greater this will result in no text showing. To fix this you have to add the embedAsCFF=”false” parameter to the middle like this:

[Embed(source = "assets/nokiafc22.ttf", embedAsCFF="false", fontFamily = "nokiafc22")]private const myFont:Class;
June 23, 2010 / Rob Fox

Clearing out an array

I’ll give you three ways of clearing out an array, starting from the slowest syntax.

while(myArray.length > 0)myArray.pop(); //slow
myArray.length = 0; //medium
myArray = []; //fast
May 12, 2010 / Rob Fox

Creating random bitmaps in Actionscript 3.0

Creating random bitmaps with actionscript 3.0 is rather easy.

Read more…