2012-11-08 55 views
1

Scroller可以添加到mxml中的Richeditabletext中。Actionscript ::如何將Scroller添加到Actionscript中的Richeditabletext

<s:BorderContainer> 
    <s:Scroller width="335" height="265" > 
     <s:RichEditableText backgroundColor="0x900000" id='_text' color="0x000000" width="335" height="265" text="Hellooooo"/> 
    </s:Scroller> 
</s:BorderContainer> 

但在Actionscript中實現了相同的拋出參數錯誤

ArgumentError: This operation is not supported. 
at spark.components::Scroller/addElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Scroller.as:2277] 

通過拋出錯誤提前

var bc:BorderContainer = new BorderContainer(); 
var scroller:Scroller = new Scroller(); 
var richEditableText:RichEditableText = new RichEditableText(); 
scroller.addElement(richEditableText); 
bc.addElement(richEditableText); 
changedTextComponent.addElement(bc); 

感謝ActionScript代碼..

+0

就是要silly..Or說明問題不明確。 – Sushant

回答

3

嗨下面的代碼可以幫助你: -

而不是scroller.addElement(richEditableText);更換scrollRTE.viewport =的RichEditableText,問題就解決了......

BorderContainerClass.as

package 
{ 
    import spark.components.BorderContainer; 
    import spark.components.RichEditableText; 
    import spark.components.Scroller; 

    public class BorderContainerClass extends BorderContainer 
    { 
     public function BorderContainerClass() 
     { 
      super(); 
     } 

     private var scrollRTE:Scroller; 
     private var richEditableText:RichEditableText; 

     override protected function createChildren():void 
     { 
      if(!scrollRTE) 
      { 
       scrollRTE = new Scroller(); 
       scrollRTE.width = 335; 
       scrollRTE.height = 265; 
      } 
      if(!richEditableText) 
      { 
       richEditableText = new RichEditableText(); 
      } 
      richEditableText.setStyle('backgroundColor','0x900000'); 
      richEditableText.setStyle('color','0x000000'); 
      richEditableText.width = 335; 
      richEditableText.height= 265; 
      richEditableText.text="Hellooooo"; 
      scrollRTE.viewport = richEditableText 
      this.addElement(scrollRTE); 
     } 
    } 
} 
相關問題