GetByIntuition()

Icon

General scripting malarky.

Debug colourisation in flash develop

You can colourise your output text in flash develop by prefixing your trace string with “n:”
By default:

0: is gray
1: is black
2: is orange
3: is red
4: is pink

Here is the result of the following:

for ( var debug: int = 0 ; debug < 20 ; debug++) {
     trace(debug+ ": debug " + debug);
}

Handy when you have a lot of traces and need to debug.

Singleton pattern with static initializer

I’m going to start posting code extracts :)
Maybe someone will find this helpful.

package
{
	/**
	 * ...
	 * @author Dwayne Bull
	 * @website http://www.dwaynebull.co.uk
	 * ...
	 */
	public final class SingletonExample
	{
		private namespace enforcer = "stop";
		enforcer static var accessable : Boolean = false;
		private static var instance : SingletonExample = null;

		{
			enforcer::accessable = true;
			instance = new SingletonExample();
			enforcer::accessable = false;
		}

		public static function getInstance():SingletonExample
		{
			return instance
		}

		public function SingletonExample()
		{
			if (!enforcer::accessable) throw new Error("SingletonExample() - Singleton, please use getInstance()");
		}

	}
}

Thanks also to gskinner for the idea.

Categories