AS3 addFrameScript(); tips

So I recently had to move a lot of code from the timeline to a document class, mainly to be able to code in my favourite code editor. Anyway I thought I would share a little trick I used to handle the multiple frames code was scattered on.

All this snippet does is add the frame scripts for every frame in a swf no matter how many frames there is.
I use generic function names ‘frame1′, ‘frame2′ and so on depending on the frame number.

Code:

public function addFrameScripts():void
{
	var i:uint = 0;
	var numFrames:int = totalFrames;
 
	for ( i; i < numFrames; i++ )
	{
		addFrameScript( i, this[ 'frame' + ( i + 1 ).toString()]);
	}
}

Another thing to note is if you are using variables and functions across the timeline you will need to make them public to make sure they can be accessed on any frame. I tripped up on this and thought it would be useful to know ;) .

Vote in HexoSearch

Whats all the HYPE about?

Wow, not posted in some time…
So winter is rolling round here in the UK, which means less time at the skatepark.

More time trying to push myself with geeky things.

One thing that has helped is HYPE.

The open-source framework developed by Joshua Davis and Branden Hall which lets developers express their creative side. I suggest taking a look if you already have not.

The core of it is relatively simple but it’s what you can build and extend from it which is amazing. Simple little experiments coded in 10 minutes which result in visual enjoyment.

I’m looking forward to posting my own exmaples and experiments from HYPE. So be sure to check back!

Vote in HexoSearch

Simple Text Field – Code snippet

I find creating text fields a bit tedious at times especially when your setting numerous parameters.

So i created SimpleTextField, it extends TextField and takes up to four parameters, a TextFormat, autosize which is automatically set to left, selectable set to false and anitaliastype set to normal.

These parameters are usually the ones i need to modify on all text fields i create via code, so this class speeds up development quite a bit.

Download and modify to your liking, there are certainly more parameters to be used or removed like embed fonts or even the text to be displayed.

Download: SimpleTextField.as

Code:

package com.arcticcode.greenFlames.text
{
	import flash.text.TextField;
	import flash.text.TextFormat;
 
	public class SimpleTextField extends TextField
	{
		public function SimpleTextField(textFormat:TextFormat=null, autoSize:String = "left", selectable:Boolean = false, antiAliasType:String = "normal")
		{
			super();
			this.autoSize = autoSize;
			this.defaultTextFormat = textFormat;
			this.selectable = selectable;
			this.antiAliasType = antiAliasType;
		}
		public function move(x:Number, y:Number):void
		{
			super.x = x;
			super.y = y;
		}
	}
}
Vote in HexoSearch

nd3d…

Probably the easiest 3D engine i have used so far, and looks to be very promising.

Go get it:

Google Code

API Docs

Vote in HexoSearch

De Monster Debugger – Video Intro

Download De Monster Debugger here

Apologies for the speed, and there being no voice over but it’s pretty simple to follow. The video simply shows how to download, install and use with a simple Actionscript Project in Flex Builder 3.

Watch online at Vimeo

Download

Vote in HexoSearch