可以将滚动条添加到mxml中的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中实现的相同会抛出Argument Error
ArgumentError: This operation is not supported.
at spark.components::Scroller/addElement()[E:\dev\4.y\frameworks\projects\spark\src\spark\components\Scroller.as:2277]
引发错误的ActionScript代码
var bc:BorderContainer = new BorderContainer();
var scroller:Scroller = new Scroller();
var richEditableText:RichEditableText = new RichEditableText();
scroller.addElement(richEditableText);
bc.addElement(richEditableText);
changedTextComponent.addElement(bc);
提前致谢..
答案 0 :(得分: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);
}
}
}