Flex id contentGroup query

2019-09-19 01:53发布

问题:

iam learning Flex and practising skins. So, i just had one doubt:

I have written one custom skin named : ApplicationContainerSkin.mxml

<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" 
             xmlns:s="library://ns.adobe.com/flex/spark" 
             xmlns:mx="library://ns.adobe.com/flex/mx">

    <s:states>
        <s:State name="normal" />
        <s:State name="disabled" />
    </s:states>


    <fx:Metadata>
        [HostComponent("spark.components.Application")]
    </fx:Metadata>


    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>

    <s:Group horizontalCenter="0" verticalCenter="0">

        <s:Rect left="0" right="0" top="0" bottom="0"
                radiusX="10" radiusY="10">
            <s:fill>
                <s:SolidColor color="#CCCCCC" />
            </s:fill>
        </s:Rect>


        <s:Group id="contentGroup"
                 left="30" right="30" top="30" bottom="30">

        </s:Group>

    </s:Group>

</s:SparkSkin>

My Doubt: When I removed s:Group id="contentGroup" , iam unable to see any content inside my application, so why is this 'contentGroup' id necessary?

where this id predefinedly specified.? sorry if its a noob query, but iam eager to knew it.I even tried to check the source code, but I didnt found it, Could anyone tell me where it specified and how does my content render only after using this contentGroup id...? ( I mean, how it internally works? )

Awaiting your responses!

回答1:

Skinnable Spark components specify "skin parts," identified by the id.

The Application component, which you are skinning, defines 2 skin parts - contentGroup and controlBarGroup, as you can see in the documentation here: http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/Application.html#SkinPartSummary

The Application class uses the contentGroup skin part (if it has been added in the skin) to lay out the content. Skin parts can either be required or not. The contentGroup part is not required, and therefore when you left it out, the content just did not display.