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:
Superclass:
class Animal
{
var foo:Function = function():void {trace("Animal"); }
}
Subclass:
class Cat extends Animal
{
function Cat()
{
super.foo = function():void {trace("Cat"); }
super.foo();
}
}
http://www.kirupa.com/forum/showthread.php?p=2596839#post2596839
Image from http://en.wikipedia.org/wiki/XML
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.
Example:
//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…
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:
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 Console.as. 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;
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;
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
A problem that has been haunting me for a while is that whenever I update my flash file on the server my browser still loads the file from cache.
To overcome the problem you need to set a different URL each time you request the file. To do so I write “?d=” followed by different numbers than the numbers that where used to load the file before.
In code I set the current time as the number in the end:
"yourURL" + "?d=" + new Date().getTime().toString();
If you don’t want your visitors to always reload the page you could set the number to be generated only by the date or even manually change them.

