Search code examples
apache-flexactionscriptmxml

How can I access the property of an ellipse inside a group in ActionScript?


Let's say I have the following MXML:

        <s:Group id="b01">
            <s:Ellipse x="267" y="96" width="30" height="28">
                <s:stroke>
                    <s:SolidColorStroke color="white" weight="1" />
                </s:stroke>
                <s:fill>
                    <s:SolidColor color="#F2FF00" alpha="0.5" />
                </s:fill>
            </s:Ellipse>
        </s:Group>

And that I have a dozen more of these groups with different ID's. How can I modify the fill color of each Ellipse using ActionScript? I know I can do something like this:

b01.getElementAt(0).width;

And that will give me the width of the Ellipse. But how can I access the SolidColorStroke color or the SolidColor fill?


Solution

  • To change the color you can use:

    SolidColor(Ellipse(b01.getElementAt(0)).fill).color = 0xFF0000;
    

    or you can set a id to each s:SolidColor tag --as you did for s:Group tag -- and change its color via id.color = 0xFF0000;

    <s:Group id="b01">
        ...
            <s:fill>
                <s:SolidColor id="f01" color="#F2FF00" alpha="0.5" />
            </s:fill>
        ...
    </s:Group>