滚动条使用示例

function setContent(txt:String):void {
	_text.htmlText=txt;//传入文字内容

	var isShow:Boolean=_text.textHeight>maskMC.height?true:false;//根据文本内容高度是否超过遮罩高度,判断是否需要显示滚动条
	scrollBar=new ScrollBar(isShow,maskMC.height);
	scrollBar.x=maskMC.x+maskMC.width-scrollBar.width;
	scrollBar.y=maskMC.y;

	scrollBar.setHeight(maskMC.height);
	scrollBar.addEventListener(Event.CHANGE,onScrolling,false,0,true);
	addChild(scrollBar);
}

function onScrolling(e:Event):void {
	_text.y = maskMC.y-(_text.height-maskMc.height)*scrollBar.txt;
}
原文地址:https://www.cnblogs.com/leon3286/p/1757108.html