How to access an object's declarations with actionscript?

Go To StackoverFlow.com

0

I would like to iterate through an object's validators. Validators must be declared in a declarations tag. How does one scroll through declarations? If one cannot, is there a better of locating all validators other than scrolling through all properties of an object?

2012-04-04 04:51
by MetaChrome
I don't understand the question.. - Marty 2012-04-04 04:56


2

Just put the Validators in a collection (an Array for instance). After that you can simply loop over the collection's items.

<fx:Declarations>
    <fx:Array id="validators">
        <mx:StringValidator source="{firstnameInput}" property="text" required="true" />
        <mx:StringValidator source="{lastnameInput}" property="text" required="true" />
        <mx:EmailValidator source="{emailInput}" property="text" required="true" />
        <mx:DateValidator source="{dateInput}" property="text" required="false" />
    </fx:Array>
</fx:Declarations>

You can then simply use 'validateAll()':

Validator.validateAll(validators);

or loop over the Validators:

for each (var validator:Validator in validators) { ... }
2012-04-04 09:31
by RIAstar


1

I'm not sure if I understand your question correctly, but if you want to iterate over all properties of a class (including meta tags), you can use describeType.

To include meta tags, make sure you've set the appropriate compiler option keep-as3-metadata correctly.

2012-04-04 06:34
by weltraumpirat
Ads