Jerome
unread,Feb 2, 2011, 10:34:04 AM2/2/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to MinimalComps
Hello,
I use MinimalConfigurator and I really enjoy it. However I think it
could be more usable. Let me explain :
We can have an heavy, unreadable XML config like this :
var xml:XML = <comps>
<VBox id="vbox">
<HUISlider id="tx" label="x" width="300" labelPrecision="0"
tick="1" minimum="-50" maximum="150" value={test.x}
event="change:onSliderChange"/>
<HUISlider id="ty" label="y" width="300" labelPrecision="0"
tick="1" minimum="-50" maximum="150" value={test.y}
event="change:onSliderChange"/>
<HUISlider id="twidth" label="width" width="300"
labelPrecision="0" tick="1" minimum="-20" maximum="400"
value={test.width} event="change:onSliderChange"/>
<HUISlider id="theight" label="height" width="300"
labelPrecision="0" tick="1" minimum="-20" maximum="200"
value={test.height} event="change:onSliderChange"/>
</VBox>
</comps>;
configurator = new MinimalConfigurator(this);
configurator.parseXML(xml);
//
You can see that I create here 4 HUISlider. And each override basic
values like width, labelPrecision, tick, ...
A cool idea could be to define an optional XML that can set default
value for each component. For example :
var default:XML = <comps>
<HUISlider width="300" labelPrecision="0" tick="1" minimum="-50"
maximum="150" event="change:onSliderChange"/>
</comps>;
then create the config XML :
var xml:XML = <comps>
<VBox id="vbox">
<HUISlider id="tx" label="x" value={test.x} />
<HUISlider id="ty" label="y"value={test.y} />
<HUISlider id="twidth" label="width" minimum="-20" maximum="400"
value={test.width} />
<HUISlider id="theight" label="height" minimum="-20" maximum="200"
value={test.height} />
</VBox>
</comps>;
then initialize like that :
configurator = new MinimalConfigurator(this, default);
configurator.parseXML(xml);
with a signature like that :
MinimalConfigurator(DisplayObjectContainer, default:XML = null);
The default XML is just stored. When you parse the configXML to create
the Components. If the node name exists in the default XML stored, and
if the attibutes stored doesn't exists in the current parsed node of
the config file, you use it for the setup.
What do you think ?