-
var ui:QuickUI = new QuickUI();
-
ui.x = 20;
-
ui.y = 260;
-
ui.addEventListener(Event.CHANGE, onChange);
-
addChild(ui);
-
-
var spriteA:Sprite = makeSprite(150,150,0xFF0000);
-
spriteA.addEventListener(MouseEvent.CLICK, onShowAddProps);
-
-
var spriteB:Sprite = makeSprite(350,150, 0xCC6600);
-
spriteB.addEventListener(MouseEvent.CLICK, onShowExcludeProps);
-
-
var spriteC:Sprite = makeSprite(550,150, 0x550066);
-
spriteC.addEventListener(MouseEvent.CLICK, onShowExcludeProps);
-
-
function onChange(evt:Event):void{
-
// updates the property on the current target object
-
ui.updateObject(evt.target);
-
}
-
function onShowAddProps(evt:MouseEvent):void{
-
ui.rows = 3;
-
// onle show the following properties
-
// add(property, label)
-
ui.add("name", "name:");
-
ui.add("x", "x location:");
-
ui.add("y", "y location:");
-
ui.add("scaleX", "x scale:");
-
ui.add("buttonMode", "show hand cursor");
-
ui.create(evt.currentTarget);
-
ui.window({title:"Select Properties: "+ evt.currentTarget.name});
-
}
-
-
function onShowExcludeProps(evt:MouseEvent):void {
-
ui.rows = 5;
-
// don't show a few select properties - if add() is not called
-
// all properties will be shown
-
ui.exclude("doubleClickEnabled");
-
ui.exclude("useHandCursor");
-
// build the UI, give two custom labels to x and y properties
-
ui.create(evt.currentTarget, {x:"x loc:", y:"y loc:"});
-
// optionally render a window behind the UI elements
-
ui.window({title:"All Properties: " + evt.currentTarget.name});
-
}
-
-
-
function makeSprite(xp:Number, yp:Number, col:uint):Sprite{
-
var s:Sprite = Sprite(addChild(new Sprite()));
-
s.x = xp;
-
s.y = yp;
-
s.buttonMode = true;
-
with (s.graphics) beginFill(col), drawRect(-40, -40, 80, 80);
-
return s;
-
}
This snippet is my first stab at creating a library that makes certain types of UI creation very easy. It works by automatically creating input text fields and check boxes for all public properties that make sense with that type of UI. It has a long way to go, but this is a good start
Take a look at the swf to get an idea of what this snippet does.
Download the source for the library and the fla for the above demo.
I hope to get this library to the point that it will at least be useful for internal UI - that is, for level editors and mini-cms systems.