fl.controls
public class UIScrollBar
继承UIScrollBar Inheritance ScrollBar Inheritance UIComponent Inheritance Sprite Inheritance DisplayObjectContainer Inheritance InteractiveObject Inheritance DisplayObject Inheritance EventDispatcher Inheritance Object

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

UIScrollBar 类包括所有滚动条功能,只是增加了 scrollTarget() 方法,因此可以被附加到 TextField 组件实例。

注意:在使用 ActionScript 更新 TextField 组件的影响文本布局的属性时,必须对 UIScrollBar 组件实例调用 update() 方法以刷新其滚动属性。 属于 TextField 组件的文本布局属性的示例包括 widthheightwordWrap

查看示例




公共 属性
 属性定义方
 InheritedaccessibilityProperties : AccessibilityProperties
此显示对象的当前辅助功能选项。
DisplayObject
 Inheritedalpha : Number
指示指定对象的 Alpha 透明度值。
DisplayObject
 InheritedblendMode : String
BlendMode 类中的一个值,用于指定要使用的混合模式。
DisplayObject
 InheritedbuttonMode : Boolean
指定此 sprite 的按钮模式。
Sprite
 InheritedcacheAsBitmap : Boolean
如果设置为 true,则 Flash Player 将缓存显示对象的内部位图表示形式。
DisplayObject
 Inheritedconstructor : Object
对类对象或给定对象实例的构造函数的引用。
Object
 InheritedcontextMenu : ContextMenu
指定与此对象相关联的上下文菜单。
InteractiveObject
  direction : String
获取或设置一个值,该值指示滚动条是水平滚动还是垂直滚动。
UIScrollBar
 InheriteddoubleClickEnabled : Boolean
指定此对象是否接收 doubleClick 事件。
InteractiveObject
 InheriteddropTarget : DisplayObject
[read-only] 指定拖动 sprite 时经过的显示对象,或放置 sprite 的显示对象。
Sprite
 Inheritedenabled : Boolean
获取或设置一个布尔值,该值指示是否启用滚动条。
ScrollBar
 Inheritedfilters : Array
包含当前与显示对象关联的每个滤镜对象的索引数组。
DisplayObject
 InheritedfocusEnabled : Boolean
获取或设置一个布尔值,该值指示组件是否可以在用户单击它后获得焦点。
UIComponent
 InheritedfocusManager : IFocusManager
获取或设置为此组件及其同级组件控制焦点的 FocusManager。
UIComponent
 InheritedfocusRect : Object
指定此对象是否显示焦点矩形。
InteractiveObject
 Inheritedgraphics : Graphics
[read-only] 指定属于此 sprite 的 Graphics 对象,在此 sprite 中可执行矢量绘画命令。
Sprite
 Inheritedheight : Number
获取或设置组件的高度,以像素为单位。
ScrollBar
 InheritedhitArea : Sprite
指定一个 sprite 用作另一个 sprite 的点击区域。
Sprite
 InheritedlineScrollSize : Number
获取或设置一个值,该值表示按下滚动条轨道时页面滚动的增量。
ScrollBar
 InheritedloaderInfo : LoaderInfo
[read-only] 返回一个 LoaderInfo 对象,其中包含加载此显示对象所属的文件的相关信息。
DisplayObject
 Inheritedmask : DisplayObject
调用显示对象被指定的 mask 对象遮罩。
DisplayObject
 InheritedmaxScrollPosition : Number
获取或设置表示最高滚动位置的数字。
ScrollBar
 InheritedminScrollPosition : Number
获取或设置表示最低滚动位置的数字。
ScrollBar
 InheritedmouseChildren : Boolean
确定对象的子项是否支持鼠标。
DisplayObjectContainer
 InheritedmouseEnabled : Boolean
指定此对象是否接收鼠标消息。
InteractiveObject
 InheritedmouseFocusEnabled : Boolean
获取或设置一个值,该值指示组件是否可以在用户单击它后获得焦点。
UIComponent
 InheritedmouseX : Number
[read-only] 指示鼠标位置的 x 坐标,以像素为单位。
DisplayObject
 InheritedmouseY : Number
[read-only] 指示鼠标位置的 y 坐标,以像素为单位。
DisplayObject
 Inheritedname : String
指示 DisplayObject 的实例名称。
DisplayObject
 InheritednumChildren : int
[read-only] 返回此对象的子项数目。
DisplayObjectContainer
 InheritedopaqueBackground : Object
指定显示对象是否由于具有某种背景颜色而不透明。
DisplayObject
 InheritedpageScrollSize : Number
获取或设置一个值,该值表示按下滚动条轨道时页面滚动的增量。
ScrollBar
 InheritedpageSize : Number
获取或设置页中所包含的行数。
ScrollBar
 Inheritedparent : DisplayObjectContainer
[read-only] 指示包含此显示对象的 DisplayObjectContainer 对象。
DisplayObject
 Inheritedprototype : Object
[static] 对类或函数对象的原型对象的引用。
Object
 Inheritedroot : DisplayObject
[read-only] 对于加载的 SWF 文件中的显示对象,root 属性是此 SWF 文件所表示的显示列表树结构部分中的顶级显示对象。
DisplayObject
 Inheritedrotation : Number
指示 DisplayObject 实例距其原始方向的旋转程度,以度为单位。
DisplayObject
 Inheritedscale9Grid : Rectangle
当前有效的缩放网格。
DisplayObject
 InheritedscaleX : Number
将组件的当前宽度与缩放系数相乘。
UIComponent
 InheritedscaleY : Number
将组件的当前高度与缩放系数相乘。
UIComponent
 InheritedscrollPosition : Number
获取或设置当前滚动位置并更新滑块的位置。
ScrollBar
 InheritedscrollRect : Rectangle
显示对象的滚动矩形范围。
DisplayObject
  scrollTarget : TextField
将 TextField 组件实例注册到 ScrollBar 组件实例中。
UIScrollBar
 InheritedsoundTransform : SoundTransform
控制此 sprite 中的声音。
Sprite
 Inheritedstage : Stage
[read-only] 显示对象的舞台。
DisplayObject
 InheritedtabChildren : Boolean
确定对象的子项是否支持 Tab 键。
DisplayObjectContainer
 InheritedtabEnabled : Boolean
指定此对象是否遵循 Tab 键顺序。
InteractiveObject
 InheritedtabIndex : int
指定 SWF 文件中的对象按 Tab 键顺序排列。
InteractiveObject
 InheritedtextSnapshot : TextSnapshot
[read-only] 返回此 DisplayObjectContainer 实例的 TextSnapshot 对象。
DisplayObjectContainer
 Inheritedtransform : Transform
一个对象,具有与显示对象的矩阵、颜色转换和像素范围有关的属性。
DisplayObject
 InheriteduseHandCursor : Boolean
布尔值,指示当鼠标滑过其 buttonMode 属性设置为 true 的 sprite 时是否显示手指形(手形光标)。
Sprite
 Inheritedversion : String = "3.0.0.13"
组件的版本号。
UIComponent
 Inheritedvisible : Boolean
获取或设置一个值,该值指示当前组件实例是否可见。
UIComponent
 Inheritedwidth : Number
获取或设置组件的宽度(以像素为单位)。
ScrollBar
 Inheritedx : Number
获取或设置 x 坐标,该坐标表示组件在其父容器内沿 x 轴的位置。
UIComponent
 Inheritedy : Number
获取或设置 y 坐标,该坐标表示组件在其父容器内沿 y 轴的位置。
UIComponent
公共 方法
 方法定义方
  
创建新的 UIScrollBar 组件实例。
UIScrollBar
 Inherited
将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。
DisplayObjectContainer
 Inherited
将一个 DisplayObject 子实例添加到该 DisplayObjectContainer 实例中。
DisplayObjectContainer
 Inherited
addEventListener(type:String, listener:Function, useCapture:Boolean = false, priority:int = 0, useWeakReference:Boolean = false):void
使用 EventDispatcher 对象注册事件侦听器对象,以使侦听器能够接收事件通知。
EventDispatcher
 Inherited
指示安全限制是否会导致出现以下情况:在列表中忽略了使用指定 point 点调用 DisplayObjectContainer.getObjectsUnderPoint() 方法时返回的所有显示对象。
DisplayObjectContainer
 Inherited
删除此组件实例中的样式属性。
UIComponent
 Inherited
确定指定显示对象是 DisplayObjectContainer 实例的子项还是该实例本身。
DisplayObjectContainer
 Inherited
将事件调度到事件流中。
EventDispatcher
 Inherited
在此组件上显示或隐藏焦点指示符。
UIComponent
 Inherited
启动立即绘制操作,但不像 invalidateNow 那样使全部设置失效。
UIComponent
 Inherited
getBounds(targetCoordinateSpace:DisplayObject):Rectangle
返回一个矩形,该矩形定义相对于 targetCoordinateSpace 对象坐标系的显示对象区域。
DisplayObject
 Inherited
返回位于指定索引处的子显示对象实例。
DisplayObjectContainer
 Inherited
返回具有指定名称的子显示对象。
DisplayObjectContainer
 Inherited
返回 DisplayObject 的 child 实例的索引位置。
DisplayObjectContainer
 Inherited
检索当前具有焦点的对象。
UIComponent
 Inherited
返回对象的数组,这些对象位于指定点下,并且是该 DisplayObjectContainer 实例的子项(或孙子项,依此类推)。
DisplayObjectContainer
 Inherited
getRect(targetCoordinateSpace:DisplayObject):Rectangle
返回一个矩形,该矩形根据 targetCoordinateSpace 参数定义的坐标系定义显示对象的边界,但不包括形状上的任何笔触。
DisplayObject
 Inherited
检索组件的样式查找链中设置的样式属性。
UIComponent
  
[static] 检索当前组件的默认样式映射。
UIScrollBar
 Inherited
将 point 对象从舞台(全局)坐标转换为显示对象的(本地)坐标。
DisplayObject
 Inherited
检查 EventDispatcher 对象是否为特定事件类型注册了任何侦听器。
EventDispatcher
 Inherited
指示对象是否已经定义了指定的属性。
Object
 Inherited
计算显示对象,以确定它是否与 obj 显示对象重叠或相交。
DisplayObject
 Inherited
hitTestPoint(x:Number, y:Number, shapeFlag:Boolean = false):Boolean
计算显示对象,以确定它是否与 x 和 y 参数指定的点重叠或相交。
DisplayObject
 Inherited
invalidate(property:String, callLater:Boolean = true):void
在未另外指定的情况下,将属性标记为无效,并在下一帧上重绘组件。
UIComponent
 Inherited
指示 Object 类的实例是否在指定为参数的对象的原型链中。
Object
 Inherited
将 point 对象从显示对象的(本地)坐标转换为舞台(全局)坐标。
DisplayObject
 Inherited
[static] 将多个类的样式合并到一个对象中。
UIComponent
 Inherited
将组件移动到其父项内的指定位置。
UIComponent
 Inherited
指示指定的属性是否存在、是否可枚举。
Object
 Inherited
从 DisplayObjectContainer 实例的子列表中删除指定的 child DisplayObject 实例。
DisplayObjectContainer
 Inherited
从 DisplayObjectContainer 的子列表中指定的 index 位置删除子 DisplayObject。
DisplayObjectContainer
 Inherited
removeEventListener(type:String, listener:Function, useCapture:Boolean = false):void
从 EventDispatcher 对象中删除侦听器。
EventDispatcher
 Inherited
更改现有子项在显示对象容器中的位置。
DisplayObjectContainer
 Inherited
设置此组件的焦点。
UIComponent
 Inherited
设置循环操作动态属性的可用性。
Object
  
setScrollProperties(pageSize:Number, minScrollPosition:Number, maxScrollPosition:Number, pageScrollSize:Number = 0):void
设置 ScrollBar 组件的范围和视口大小。
UIScrollBar
 Inherited
setSize(width:Number, height:Number):void
将组件设置为指定宽度和高度。
ScrollBar
 Inherited
setStyle(style:String, value:Object):void
对此组件实例设置样式属性。
UIComponent
 Inherited
startDrag(lockCenter:Boolean = false, bounds:Rectangle = null):void
允许用户拖动指定的 Sprite。
Sprite
 Inherited
结束 startDrag() 方法。
Sprite
 Inherited
交换两个指定子对象的 Z 轴顺序(从前到后顺序)。
DisplayObjectContainer
 Inherited
swapChildrenAt(index1:int, index2:int):void
在子级列表中两个指定的索引位置,交换子对象的 Z 轴顺序(前后顺序)。
DisplayObjectContainer
 Inherited
返回指定对象的字符串表示形式。
Object
  
强制滚动条立即更新其 scroll 属性。
UIScrollBar
 Inherited
验证并更新此对象的属性和布局,如果需要的话重绘对象。
UIComponent
 Inherited
返回指定对象的原始值。
Object
 Inherited
检查是否用此 EventDispatcher 对象或其任何始祖为指定事件类型注册了事件侦听器。
EventDispatcher
事件
 事件摘要定义方
 Inherited Flash Player 获得操作系统焦点并变为活动状态时调度。EventDispatcher
 Inherited 将显示对象添加到显示列表中时调度。DisplayObject
 Inherited 在将显示对象直接添加到舞台显示列表或将包含显示对象的子树添加至舞台显示列表中时调度。DisplayObject
 Inherited 用户在同一 InteractiveObject 上按下并释放用户指针设备的主按钮时调度。InteractiveObject
 Inherited Flash Player 失去操作系统焦点并变为非活动状态时调度。EventDispatcher
 Inherited 如果 InteractiveObject 的 doubleClickEnabled 标志设置为 true,当用户在该对象上快速连续按下两次并释放指针设备的主按钮时调度。InteractiveObject
 Inherited 播放头进入新帧时调度。DisplayObject
 Inherited 显示对象获得焦点后调度。InteractiveObject
 Inherited 显示对象失去焦点后调度。InteractiveObject
 Inherited 在组件可见性从可见改为不可见以后调度。UIComponent
 Inherited 用户按下某个键时调度。InteractiveObject
 Inherited 用户尝试使用键盘导航更改焦点时调度。InteractiveObject
 Inherited 用户释放某个键时调度。InteractiveObject
 Inherited 在 Flash Player 窗口中,用户在 InteractiveObject 实例上按下指针设备按钮时调度。InteractiveObject
 Inherited 用户尝试使用指针设备更改焦点时调度。InteractiveObject
 Inherited 用户移动 InteractiveObject 上的指针设备时调度。InteractiveObject
 Inherited 用户将指针设备从 InteractiveObject 实例上移开时调度。InteractiveObject
 Inherited 在 Flash Player 窗口中,用户将指针设备移动到 InteractiveObject 实例上时调度。InteractiveObject
 Inherited 在 Flash Player 窗口中,用户在 InteractiveObject 实例上释放指针设备按钮时调度。InteractiveObject
 Inherited 在 Flash Player 窗口中,鼠标滚轮滚动到 InteractiveObject 实例上时调度。InteractiveObject
 Inherited 在移动组件以后调度。UIComponent
 Inherited 将要从显示列表中删除显示对象时调度。DisplayObject
 Inherited 在从显示列表中直接删除显示对象或删除包含显示对象的子树时调度。DisplayObject
 Inherited 将要更新和呈现显示列表时调度。DisplayObject
 Inherited 在调整组件大小以后调度。UIComponent
 Inherited 用户将指针设备从 InteractiveObject 实例上移开时调度。InteractiveObject
 Inherited 用户将指针设备移动到 InteractiveObject 实例上时调度。InteractiveObject
 Inherited 当 ScrollBar 实例的 scrollPosition 属性发生变化时调度。ScrollBar
 Inherited 在组件可见性从不可见改为可见以后调度。UIComponent
 Inherited 对象的 tabChildren 标志值发生更改时调度。InteractiveObject
 Inherited 对象的 tabEnabled 标志发生更改时调度。InteractiveObject
 Inherited 对象的 tabIndex 属性值发生更改时调度。InteractiveObject
样式
 样式说明定义方
 Inherited 类型: flash.text.TextFormat
用于在禁用了按钮的情况下呈现组件标签的 TextFormat 对象。 默认值为 TextFormat("_sans", 11, 0x999999, false, false, false, '', '', TextFormatAlign.LEFT, 0, 0, 0, 0).
UIComponent
 Inherited 类型: Class
类的名称,该类用作当禁用了滚动条时滚动条的向下箭头按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowDown_disabledSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当单击滚动条的向下箭头按钮时该按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowDown_downSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当鼠标指针在滚动条的向下箭头按钮上方时该按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowDown_overSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作滚动条的向下箭头按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowDown_upSkin.
ScrollBar
 Inherited 类型: Number   格式: Length
用于分隔组件的外边框和焦点指示符的外边框的填充(以像素为单位)。 默认值为 2.
UIComponent
 Inherited 类型: Class
用于显示焦点指示符的外观。 默认值为 focusRectSkin.
UIComponent
 Inherited 类型: Number   格式: Time
在第一次调度 buttonDown 事件之后、发送第二个 buttonDown 事件之前等待的毫秒数。. 默认值为 500.
ScrollBar
 Inherited 类型: Number   格式: Time
在由 repeatDelay 样式指定的延迟之后调度的 buttonDown 事件之间的间隔(以毫秒为单位)。. 默认值为 35.
ScrollBar
 Inherited 类型: flash.text.TextFormat
用于呈现组件标签的 TextFormat 对象。 默认值为 TextFormat("_sans", 11, 0x000000, false, false, false, '', '', TextFormatAlign.LEFT, 0, 0, 0, 0).
UIComponent
 Inherited 类型: Class
用于指示缩略图的禁用状态的外观。 默认值为 ScrollThumb_disabledSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当单击滚动条的缩略图时该缩略图的外观。 默认值为 ScrollThumb_downSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作滚动条的缩略图的图标。 默认值为 ScrollBar_thumbIcon.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当鼠标指针在滚动条的缩略图上方时该缩略图的外观。 默认值为 ScrollThumb_overSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作滚动条的缩略图的外观。 默认值为 ScrollThumb_upSkin.
ScrollBar
 Inherited 类型: Class
用于指示被禁用轨道的外观。 默认值为 ScrollTrack_Skin.
ScrollBar
 Inherited 类型: Class
用于指示被禁用外观的按下状态的外观。 默认值为 ScrollTrack_Skin.
ScrollBar
 Inherited 类型: Class
用于指示滚动轨道的鼠标悬停状态的外观。 默认值为 ScrollTrack_Skin.
ScrollBar
 Inherited 类型: Class
用于指示滚动轨道的鼠标松开状态的外观。 默认值为 ScrollTrack_Skin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当禁用了滚动条时滚动条的向上箭头按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowUp_disabledSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当单击滚动条的向上箭头按钮时该按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowUp_downSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作当鼠标指针在滚动条的向上箭头按钮上方时该按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowUp_overSkin.
ScrollBar
 Inherited 类型: Class
类的名称,该类用作滚动条的向上箭头按钮的外观。 如果以图形化方式或编程方式更改该外观,您应当确保新外观与轨道具有相同的高度(对于水平滚动条)或高度(对于垂直滚动条)。 默认值为 ScrollArrowUp_upSkin.
ScrollBar
属性详细信息
direction属性
direction:String  [read-write]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

获取或设置一个值,该值指示滚动条是水平滚动还是垂直滚动。 有效值为 ScrollBarDirection.HORIZONTALScrollBarDirection.VERTICAL

默认值为 ScrollBarDirection.VERTICAL.


实现
    public function get direction():String
    public function set direction(value:String):void

另请参见


示例
如何使用示例

下例将一些文本动态加载到文本字段,并创建水平和垂直滚动条:

import fl.controls.UIScrollBar;
import fl.controls.ScrollBarDirection;

var url:String = "http://www.helpexamples.com/flash/text/lorem.txt";

var uLdr:URLLoader = new URLLoader(new URLRequest(url));
uLdr.addEventListener(Event.COMPLETE, completeHandler);

var tf:TextField = new TextField();
tf.width = 320;
tf.height = 140;
tf.x = 10;
tf.y = 10;
tf.border = true;
tf.multiline = true;
tf.wordWrap = false;
addChild(tf)

var hScrollBar:UIScrollBar = new UIScrollBar();
hScrollBar.direction = ScrollBarDirection.HORIZONTAL;
hScrollBar.move(tf.x, tf.y + tf.height);
hScrollBar.width = tf.width;
hScrollBar.scrollTarget = tf;
addChild(hScrollBar);

var vScrollBar:UIScrollBar = new UIScrollBar();
vScrollBar.direction = ScrollBarDirection.VERTICAL;
vScrollBar.move(tf.x + tf.width, tf.y);
vScrollBar.height = tf.height;
vScrollBar.scrollTarget = tf;
addChild(vScrollBar);

function completeHandler(event:Event):void {
    tf.text = event.target.data;
    hScrollBar.update();
    vScrollBar.update();
}

下例创建一个用于滚动动态文本字段的 UIScrollBar 组件实例:

import fl.controls.ScrollBarDirection;
import fl.controls.UIScrollBar;

var myTextField:TextField = new TextField();
myTextField.width = 160;
myTextField.height = 120;
myTextField.border = true;
myTextField.x = 10;
myTextField.y = 10;
addChild(myTextField);

var hScrollBar:UIScrollBar = new UIScrollBar();
hScrollBar.direction = ScrollBarDirection.HORIZONTAL;
hScrollBar.scrollTarget = myTextField;
hScrollBar.width = myTextField.width;
hScrollBar.move(myTextField.x, myTextField.y + myTextField.height);
addChild(hScrollBar);

var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener(Event.COMPLETE, completeHandler);
myURLLoader.load(new URLRequest("http://www.helpexamples.com/flash/lorem.txt"));

function completeHandler(event:Event):void {
    var txt:String = URLLoader(event.currentTarget).data as String;
    myTextField.text = txt;
    vScrollBar.update();
}
scrollTarget属性 
scrollTarget:TextField  [read-write]

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

将 TextField 组件实例注册到 ScrollBar 组件实例中。


实现
    public function get scrollTarget():TextField
    public function set scrollTarget(value:TextField):void

另请参见


示例
如何使用示例

下例创建一个 UIScrollBar,并使用 scrollTarget 属性将其链接到文本字段:

import fl.controls.UIScrollBar;

var url:String = "http://www.helpexamples.com/flash/text/lorem.txt";

var tf:TextField = new TextField();
tf.x = 10;
tf.y = 10;
tf.width = 500;
tf.height = 380;
tf.wordWrap = true;
addChild(tf);

var myScrollBar:UIScrollBar = new UIScrollBar();
myScrollBar.move(tf.x + tf.width, tf.y);
myScrollBar.height = tf.height;
myScrollBar.scrollTarget = tf;
addChild(myScrollBar);

var uLdr:URLLoader = new URLLoader();
uLdr.addEventListener(Event.COMPLETE, completeHandler);
uLdr.load(new URLRequest(url));

function completeHandler(event:Event):void {
    tf.text = URLLoader(event.target).data;
    myScrollBar.update();
}
构造函数详细信息
UIScrollBar()构造函数
public function UIScrollBar()

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

创建新的 UIScrollBar 组件实例。

方法详细信息
getStyleDefinition()方法
public static function getStyleDefinition():Object

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

检索当前组件的默认样式映射。 样式映射包含适合组件的类型,具体取决于组件使用的样式。 例如,disabledTextFormat 样式包含 null 值或 TextFormat 对象。 可以使用这些样式并对当前组件调用 setStyle()。 下面的代码覆盖指定组件上默认的 disabledTextFormat 样式:
componentInstance.setStyle("disabledTextFormat", new TextFormat());

返回
Object — 默认样式对象。

另请参见

setScrollProperties()方法 
public override function setScrollProperties(pageSize:Number, minScrollPosition:Number, maxScrollPosition:Number, pageScrollSize:Number = 0):void

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

设置 ScrollBar 组件的范围和视口大小。 ScrollBar 组件会相应地更新箭头按钮的状态和滚动滑块的大小。 所有滚动属性是相对于 minScrollPositionmaxScrollPosition 的缩放而言的。 介于最大值和最小值之间的每个数字都代表一个滚动位置。

参数

pageSize:Number — 一个页面的大小。 确定滑块的大小以及单击箭头时滚动条移动的增量。
 
minScrollPosition:Number — 滚动范围的底部。
 
maxScrollPosition:Number — 滚动范围的顶部。
 
pageScrollSize:Number (default = 0) — 单击轨道时移动的增量,以像素为单位。

另请参见

update()方法 
public function update():void

语言版本 : ActionScript 3.0
Player 版本 : Flash Player 9.0.28.0

强制滚动条立即更新其 scroll 属性。 使用 ActionScript 在指定的 scrollTarget 文本字段中添加文本后,必须执行此操作,并且需要刷新滚动条。

另请参见


示例
如何使用示例

下例创建一个用于滚动动态文本字段的 UIScrollBar 组件实例:

import fl.controls.UIScrollBar;

var myTextField:TextField = new TextField();
myTextField.wordWrap = true;
myTextField.width = 160;
myTextField.height = 120;
myTextField.border = true;
myTextField.x = 10;
myTextField.y = 10;
addChild(myTextField);

var vScrollBar:UIScrollBar = new UIScrollBar();
vScrollBar.scrollTarget = myTextField;
vScrollBar.height = myTextField.height;
vScrollBar.move(myTextField.x + myTextField.width, myTextField.y);
addChild(vScrollBar);

var myURLLoader:URLLoader = new URLLoader();
myURLLoader.addEventListener(Event.COMPLETE, completeHandler);
myURLLoader.load(new URLRequest("http://www.helpexamples.com/flash/lorem.txt"));

function completeHandler(event:Event):void {
    var txt:String = URLLoader(event.currentTarget).data as String;
    myTextField.text = txt;
    vScrollBar.update();
}
示例 如何使用示例

此示例演示了如何将 UIScrollBar 实例添加到 TextField。

若要运行该示例,请按照下列步骤操作:

  1. 将 UIScrollBar 组件添加到库中。
  2. 将该代码作为 UIScrollBarExample.as 另存到 FLA 文件所在的同一目录中。
  3. 将 FLA 文件中的 Document 类设置为 UIScrollBarExample。
package 
{
    import fl.controls.UIScrollBar;
    import flash.display.Sprite;
    import flash.text.TextField;
    
    public class UIScrollBarExample extends Sprite
    {
        private var tf:TextField;
        private var sb:UIScrollBar = new UIScrollBar();
        private var sampleText:String = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus vestibulum. Praesent in velit. Fusce scelerisque. Nullam fringilla. Aenean ut lacus at mi rutrum elementum. Suspendisse sit amet ligula et ipsum rhoncus sagittis. Aenean quis lacus. Nullam quis lorem. Integer pellentesque dictum lorem. In hendrerit lectus non orci. Sed vestibulum. Maecenas ornare, libero eu laoreet tristique, felis odio tincidunt nibh, et faucibus nibh tellus at metus. In hac habitasse platea dictumst. Nullam aliquam, dolor ut commodo dictum, ante justo dictum nisi, id suscipit elit sapien nec pede."
        
        public function UIScrollBarExample() {
            createTextField();
            assignScrollBar();
        }
        private function createTextField():void {
            tf = new TextField();
            tf.width = 200;
            tf.height = 100;
            tf.wordWrap = true;
            tf.multiline = true;
            tf.border = true;
            tf.text = sampleText;
            addChild(tf);            
        }
        private function assignScrollBar():void {
            sb = new UIScrollBar();
            sb.move(tf.x + tf.width, tf.y);
            sb.setSize(sb.width, tf.height);
            sb.scrollTarget = tf;
            addChild(sb);            
        }
    }
}




 

评论添加到页面后给我发送电子邮件 | 评论报告

当前页: http://livedocs.adobe.com/flash/9.0_cn/ActionScriptLangRefV3/fl/controls/UIScrollBar.html