An Idea to document your components.

This could be an easy way to document your component. We need track the properties and methods of a component by looping through the instance. Say for example the following example can generate the color syntax xml for any component instance, we need to delete unwanted entries manually that’s all.

<span style="color: #993300;">var</span> d = <span style="color: #000087;">_global</span>.akComponentDoc=<span style="color: #993300;">new</span> <span style="color: #993300;">Object</span>();
d.getColorSyntax = <span style="color: #993300;">function</span>(obj) {
        <span style="color: #993300;">var</span> arr = <span style="color: #993300;">new</span> <span style="color: #993300;">Array</span>();
        <span style="color: #993300;">for</span> (i <span style="color: #993300;">in</span> obj) {
                <span style="color: #993300;">if</span> (<span style="color: #993300;">typeof</span> (obj[i]) == 'function' &amp;&amp; <span style="color: #000087;">substring</span>(i, 1, 2) != "<span style="color: blue;">my</span>") {
                        arr.<span style="color: #000087;">push</span>('t&lt;identifier <span style="color: #000087;">text</span>="<span style="color: blue;">.'+i+'</span>"/<span style="color: #000087;">&gt;</span>n');
                }
        }
        arr.<span style="color: #000087;">sort</span>();
        <span style="color: #993300;">return</span> '&lt;colorsyntax<span style="color: #000087;">&gt;</span>n'+arr.<span style="color: #000087;">join</span>('')+'&lt;/colorsyntax<span style="color: #000087;">&gt;</span>n';
};
<span style="color: #993300;">trace</span>(d.getColorSyntax(PushButtonInstance));

The above code generated the xml below
&lt;colorsyntax&gt;
    &lt;identifier text=".accDoDefaultAction"/&gt;
    &lt;identifier text=".arrangeLabel"/&gt;
    &lt;identifier text=".cleanUI"/&gt;
    &lt;identifier text=".cleanUINotSize"/&gt;
    &lt;identifier text=".drawFocusRect"/&gt;
    &lt;identifier text=".drawFrame"/&gt;
    &lt;identifier text=".drawRect"/&gt;
    &lt;identifier text=".executeCallBack"/&gt;
    &lt;identifier text=".getBtnState"/&gt;
    &lt;identifier text=".getEnabled"/&gt;
    &lt;identifier text=".getLabel"/&gt;
    &lt;identifier text=".get_accDefaultAction"/&gt;
    &lt;identifier text=".get_accName"/&gt;
    &lt;identifier text=".get_accRole"/&gt;
    &lt;identifier text=".get_accState"/&gt;
    &lt;identifier text=".init"/&gt;
    &lt;identifier text=".initContentPos"/&gt;
    &lt;identifier text=".invalidate"/&gt;
    &lt;identifier text=".onDragOut"/&gt;
    &lt;identifier text=".onDragOver"/&gt;
    &lt;identifier text=".onPress"/&gt;
    &lt;identifier text=".onRelease"/&gt;
    &lt;identifier text=".onReleaseOutside"/&gt;
    &lt;identifier text=".onRollOut"/&gt;
    &lt;identifier text=".onRollOver"/&gt;
    &lt;identifier text=".pressFocus"/&gt;
    &lt;identifier text=".registerSkinElement"/&gt;
    &lt;identifier text=".setBtnState"/&gt;
    &lt;identifier text=".setChangeHandler"/&gt;
    &lt;identifier text=".setClickHandler"/&gt;
    &lt;identifier text=".setEnabled"/&gt;
    &lt;identifier text=".setHitArea"/&gt;
    &lt;identifier text=".setLabel"/&gt;
    &lt;identifier text=".setSize"/&gt;
    &lt;identifier text=".setStyleProperty"/&gt;
    &lt;identifier text=".txtFormat"/&gt;
    &lt;identifier text=".updateStyleProperty"/&gt;
&lt;/colorsyntax&gt;

Leave a Reply