开发者

Is Flex 4 Panel's controlBarContent dynamic?

I have a custom TitleWindow component (written in ActionScript) that extends spark.componenets.TitleWindow

I want to define some controls to be in the control bar but I don't have all controls at the creation stage. Also, this custom component is the base for other compone开发者_如何学编程nts which need other controls in the control bar.

Is there a way to add controls to the controlBarContent in ActionScript at run time?

Maybe something like the following? (this obviously didn't work)

controlBarContent = [];
.
.
.
controlBarContent.push(new Button());


In general, look out for

addElement()

or

addChild()

methods.

addElement() adds other UI components as sub-elements of other components.

This might be of interest. Finnaly, Adobe provides good help here: 'Working with components'.

UPDATE-1

Sorry, my fault. This works for me:

<s:Panel creationComplete="init();" id='p' controlBarVisible="true" >

    <s:controlBarContent>

        <!-- will show controls -->
        <s:Button label="dd">

        </s:Button>

    </s:controlBarContent>


    <fx:Script>
        <![CDATA[
            import mx.controls.Button;

            import spark.components.Button;

            private function init(): void {

                var s:spark.components.Label = new spark.components.Label();
                s.text = 'My Label';
                s.width = 200;

                var a:Array = new Array();
                a.push( s );

                p.controlBarVisible = false;
                p.controlBarContent = a;
                p.controlBarVisible = true;

                p.invalidateDisplayList();

            }

        ]]>
    </fx:Script>

</s:Panel>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜