Archive for the ‘Tutorials’ category

Configuring Notepad++ for pbelevel format

March 23rd, 2010

I use Notepad++ for viewing my *.pbelevel files, and always had to do the extra clicking “Language >> XML” to configure it, to display the file with XML highlighting. I now found out, how one can configure Notepad++ to do this automatically: locate the langs.xml in your Notepad++ install directory and add the following line:

<Language name="xml"  ext="pbelevel"></Language>

And tada – you’re off to go!

How to Use SWFSpriteSheetComponent (PBE)

March 12th, 2010

JD Conley from Hive7 has posted a tutorial how to use his SWFSpriteSheetComponent for the PushButton Engine. Check it out at his blog, it’s definately worth a look!

In short, using this component, you can combine, what normally is hard to achieve with Flash: animation with “thousands of buildings on the screen at once“.

Understanding Local Flash Player Security

March 7th, 2010

Nate Beck has posted a great explaination about how Flash player security works. He covers what types of sand boxes there are, and for what they are good for.
Check it out at his blog: Understanding Local Flash Player Security!

Simulate Double-Click with Actionscript

February 2nd, 2010

Using the Flash built in solution to detect double clicks with MouseEvent.DOUBLE_CLICK can turn out to be a pain, especially if you’re developing more than a simple website (no offence to those who do! ;) ). For my current project (Level Master 2000), I urgently needed such behaviour, and I didn’t want to turn on sprite.doubleClickEnabled = true for all selectable objects. So I simply implemented my own version, for which I can even adjust the click interval, such that a double click gets recognized.
It’s as simple as:

private const DOUBLE_CLICK_INTERVAL:int = 400;
private var clickIntervalTimer:int;

Somewhere, add your event listener to a normal mouse down event:

%something%.addEventListener(MouseEvent.MOUSE_DOWN, OnClick);

And then, in the OnClick, check if it was a double click:

if((getTimer() - clickIntervalTimer) < DOUBLE_CLICK_INTERVAL) 
{
    //A DOUBLE CLICK HAPPENED, DO SOMETHING!
}
 
//Don't forget to update your clickIntervalTimer afterwards:
clickIntervalTimer = getTimer();

Note: the getTimer function can be found in import flash.utils.getTimer;. Everything else should be straight forward!

Get class and super class

January 27th, 2010

For Level Master 2000, I needed two functions:

  1. getClass, which I stuff in any kind of object, and it returns me its class.
  2. getSuperClass, which I stuff in it’s class name as string, and it returns me the class name of its parent as string.

Note that first returns the class itself, and the second one works with strings. If you need to e.g. let the second one work with classes also, just adapt it like in the first function.

All in all, you need to import these functions:

import flash.utils.getDefinitionByName;
import flash.utils.getQualifiedClassName;
import flash.utils.getQualifiedSuperclassName;

And here are the two functions:

public static function getClass(obj:Object):Class
{
	return Class(getDefinitionByName(getQualifiedClassName(obj)));
}
static public function getSuperClass(className:String):String
{
	return getQualifiedSuperclassName(getDefinitionByName(className));
}

Note that getSuperClass only returns its direct parent. If you need to go further up the inheritance tree, you need to call it recursively. Highest it can get is “Object”.