AS3 Game Object Editor Metadata Syntax
- AS3 Game Object Editor
- Features
- How To
- Class Markup
- Metadata Syntax
- Documentation
- Code Repo
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 forBooleans. A simple on/off checkboxcolour: Selects a colour valueinput: The default forStrings. Allows you to enter textslider: Allows you to set aNumberbetween two values easilystatic_consts: Takes it's value from static consts in another classstepper: The default forint,uint, andNumber. Updates the value based on a numerical stepperwatch: The default for all other types. Doesn't allow editing, but is there for watching variables
Details
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:
Checkbox
[Editable( type="checkbox" )]
public var visible:Boolean = true;
If your variable is a Boolean, you can leave out the type arg.
Colour
[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.
Input
[Editable( type = "input", maxChars = 16 )]
public var name:String = null;
If your variable is a String, you can leave out the type arg. maxChars is an optional argument that lets you limit the number of characters that you can input. It defaults to 0 (any amount).
Slider
[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 to0max: The maximum value for the slider. Defaults to100step: Will snap the slider in incretements of this number. Defaults to1
Static Consts
[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. "com.divillysausages.mypackage.MyClass"). Only 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).
Stepper
[Editable( type = "stepper", min = 1.0, max = 10.0, step = 1.0 )]
public var count:int = 0;
Stepper is the default type for Number, int and uint, so it's not necessary to specify it. The other arguments are all optional.
min: The minimum value for the stepper. Defaults to0max: The maximum value for the stepper. Defaults to100step: Will snap the stepper in incretements of this number. Defaults to1
Watch
[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 Editable metatag)
Comments
Submit a comment