1 Reply Latest reply on Dec 2, 2009 6:28 AM by RK...

    Customize TitleWindow's title

    LacioDrom Level 1

      Hi everyone,


      I'd like to customize the TitleWindow's title to have words in different colors such as:

       

           Hello John


      Using titleStyleName property I can only set one color for all title's words...


      Any suggestions?


      Thanks, greetings !!!

        • 1. Re: Customize TitleWindow's title
          RK...

          You can create Customized TitleWindow (extends TitleWindow) and add textfields on titlebar,

           

          May be this code would be useful

           

          public class CustomTitleWindow extends TitleWindow {
               
               private var txtField1: UITextField = null;
               private var txtField2: UITextField = null;
               
               public function CustomTitleWindow() {
                    super();
               }
               
               override protected function createChildren(): void {
                    super.createChildren();
                    
                    if (!txtField1) {
                         txtField1 = new UITextField();
                         txtField1.text = "Hello"
                         txtField1.x = 2;
                         txtField1.y = 2;
                         if (this.getStyle("txtStyleName1")) {
                              txtField1.styleName = this.getStyle("txtStyleName1");
                         }
                         this.titleBar.addChild(txtField1);
                    }
                    
                    if (!txtField2) {
                         txtField2 = new UITextField();
                         txtField2.text = "John"
                         
                         txtField2.y = 2;
                         if (this.getStyle("txtStyleName2")) {
                              txtField2.styleName = this.getStyle("txtStyleName2");
                         }
                         this.titleBar.addChild(txtField2);
                    }
               }
               
               override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number): void {
                    super.updateDisplayList(unscaledWidth, unscaledHeight);
                    txtField2.x = txtField1.textWidth + 10;
               }
          }
          

           

          You can have getters and setters for title1 and title2

           

          You can define style like,

           

          CustomTitleWindow {
               txtStyleName1: "txtStyle1";
               txtStyleName2: "txtStyle2";
          }
          
          .txtStyle1 {
               fontFamily: Verdana;
               fontSize :10;
               fontWeight :bold;
               textAlign :left; 
               color :#FF0000;  
          }
          
          .txtStyle2 {
               fontFamily: Verdana;
               fontSize :10;
               fontWeight :bold;
               textAlign :left; 
               color :#00FF00;  
          }