2010-10-22 63 views
0

我想添加一個包含自定義類的對象的UI組件,擴展UI組件,並且我想將這個自定義組件顯示到畫布上我沒有做錯誤編譯或運行時間,但它不顯示Uicomponent。當我將UIcomponent添加到畫布時沒有任何顯示?

這裏是代碼;

var item:RecordRanderer = new RecordRanderer(); 

     item.randerItem(child); 
     item.x=20; 
     item.y = 20+ycomponent; 
     item.width = 90; 
     item.height = 200; 
     item.setStyle("backgroundColor","Red"); 

     this.addChild(item); 

記錄randerer是對自定義類,這也是也是UIComponent的擴展,它包含了一些textinputs等

現在我將它添加到畫布上,但沒有顯示

這裏是自定義類

internal class RecordRanderer extends UIComponent 
{ 
    //---------------------------------------------------- 
    //Class varibles 
    private var namelabel:Text = new Text(); 
    private var employname:TextInput = new TextInput(); 

    //---------------------------------------------------- 

    //RecordRanderer class constructor function 
    public function RecordRanderer() 
    { 
     //-------------------------------- 
     this.height = 200; 
     this.width = 200; 

     //-------------------------------- 
     //name text box and label 
     namelabel.text = "Name: "; 
     namelabel.setStyle("fontSize",12); 
     namelabel.x = 5; 
     namelabel.y = 20; 
     employname.setStyle("borderColor",0xA9C0E7); 
     employname.setStyle("cornerRadius", 15); 
     employname.setStyle("borderStyle", "Solid"); 
     employname.x = 100; 
     employname.y = 20; 

}

  public function set namevalue(val:String) 
    { 
     if(val.length > 0) 
     {  
      namelabel.x = 5; 
      namelabel.y = 10 + Height; 

      employname.text = val; 
      employname.x = 100; 
      employname.y = 10 + Height; 

      Height += 25; 

     // contain.addChild(namelabel); 
     // contain.addChild(employname); 

      this.addChild(namelabel); 
      this.addChild(employname); 

     }//end if 

    }//end function 

我有什麼用得到任何事情顯示

詢問更多細節

感謝名單

回答

1

閱讀Flex中的組件生命週期(關於SO的鏈接有多個問題)。

製作顯示組件時,您沒有遵循正確的做法。

-1

檢查你的畫布大小。此外,「紅色」和「實心」等屬性通常以小寫字母寫(不確定是否需要)。

相關問題