views:

181

answers:

1

i have this:

public class AditionalPane extends BorderContainer {
     //.....

       private function storeRetrievedData(e : Event) : void {
        var titleLabel : Label = new Label();
        titleLabel.text = "Members: ";
        titleLabel.height = 100;
        titleLabel.x = 1;
        titleLabel.y = 1;
        //titleLabel.visible = true;
        super.addElement(titleLabel);

     //.....
}

the problem is that it doesn't display nothing on the screen where is the place for titleLabel. Only the pane, without content (items). What's the problem?

+1  A: 

Are you sure that your titleLabel has a width? A zero width would, effectively, make it invisible.

A few other thoughts:

Would would you do "super.addElement()" instead of "this.addElement()"? I would expect both to work, but it is unusual syntax.

Under normal circumstances, your skin class should be positioning and sizing the titleLabel. Do you have a skin class?

Normally you would set other properties, such as 'text', in the partAdded method. So your class might be re-factored to be something like this:

public class AditionalPane extends BorderContainer {
     public function AditionalPane ():void{
      this.setStyle("skinClass", mySkin);
     }

    [SkinPart(required="true")]
    public var titleLabel : Label;

    override protected function partAdded(partName:String, instance:Object):void { 
     if (instance == titleLabel){
        titleLabel.text = "Members: ";
     }
    }
}

A Skin Class would look something like this:

<?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/halo" width="400" height="300">
    <fx:Metadata>
        <![CDATA[ 
            [HostComponent("com.something.AdditionalPane")]
        ]]>
    </fx:Metadata> 

    <s:Label id="titleLabel" x="1" y="1" height="100" />


</s:SparkSkin>
www.Flextras.com