AS3 Game Object Editor Metadata Syntax
All variable editing goes through the
Editable metatag. Depending on the variable that we want to edit, a different editing component will be created by default, although you can override this. There are currently 7 different "types":
checkbox: The default for
Booleans. A simple on/off checkbox
colour: Selects a colour value
input: The default for
Strings. Allows you to enter text
slider: Allows you to set a
Numberbetween two values easily
static_consts: Takes it's value from static consts in another class
stepper: The default for
Number. Updates the value based on a numerical stepper
watch: The default for all other types. Doesn't allow editing, but is there for watching variables
To setup a variable to be editable in your game, simply add the
Editable metadata before it.
Each type of variable that you set as editable has a
"type" by default, but it can be overridden by specifying the type directly:
// As x is a Number, its default is the 'stepper' type. Here we // override that and specify 'slider' [Editable( type = "slider" )] public var x:Number = 0.0;
Each Editable metadata tag takes different parameters depending on the type selected. Most are optional. For the full listing:
[Editable( type="checkbox" )] public var visible:Boolean = true;
If your variable is a
Boolean, you can leave out the
[Editable( type = "colour" )] public var colour:uint = 0x000000;
This will let you edit an
uint through a colour chooser component. It's not a default, so the
type needs to be specified.
[Editable( type = "input", maxChars = 16 )] public var name:String = null;
If your variable is a
String, you can leave out the
maxChars is an optional argument that lets you limit the number of characters that you can input. It defaults to
0 (any amount).
[Editable( type = "slider", min = 100.0, max = 500.0, step = 10.0 )] public var x:Number = 0.0;
Lets you set
Numbers using a slider. It's not a default, so
type needs to be specified if you want to use it. The other arguments are all optional.
min: The minimum value for the slider. Defaults to
max: The maximum value for the slider. Defaults to
step: Will snap the slider in incretements of this number. Defaults to
[Editable( type = "static_consts", clazz = "TypeConsts" )] public var type:String = null;
Lets you set a value by using
static consts from another class. It's not a default, so
type needs to be specified. The
clazz argument details the class that we want to take our consts from. It needs to be the fully qualified classname (e.g.
static consts that are the same type as the variable will be taken into account (e.g. if your variable is a
String, the only
String static consts will be taken from the class).
[Editable( type = "stepper", min = 1.0, max = 10.0, step = 1.0 )] public var count:int = 0;
Stepper is the default type for
uint, so it's not necessary to specify it. The other arguments are all optional.
min: The minimum value for the stepper. Defaults to
max: The maximum value for the stepper. Defaults to
step: Will snap the stepper in incretements of this number. Defaults to
[Editable( type="watch" )] public var x:Number = 0.0;
This specifies that we just want to watch the value of this variable (for debug purposes). You can't edit these types (I understand the irony of keeping it under the