![]() ![]() | |
若要在影片剪辑播放时更改它的属性,可编写一条为属性赋值的语句或使用 setProperty() 函数。例如,下面的代码将实例 mc 的旋转设置为 45 度:
mc._rotation = 45;
上面的语句等同于下面使用 setProperty() 函数的代码:
setProperty("mc", _rotation, 45);
有些属性是只读属性,只可以读取但不能设置它们的值。(这些属性在它们的动作脚本字典条目中被指定为只读。)下面是一些只读属性:_currentframe、_droptarget、_framesloaded、_parent、_target、_totalframes、_url、_xmouse 和 _ymouse。
可以编写语句来设置任何非只读的属性。下面的语句设置影片剪辑实例 wheel 的 _alpha 属性,该实例是 car 实例的子级:
car.wheel._alpha = 50;
此外,可以编写获取影片剪辑的属性值的语句。例如,下面的语句获取当前级别的时间轴上的 _xmouse 属性的值,并将 customCursor 实例的 _x 属性设置为该值:
onClipEvent (enterFrame) {
customCursor._x = _root._xmouse;
}
上面的语句等同于下面使用 getProperty() 函数的代码:
onClipEvent (enterFrame) {
customCursor._x = getProperty(_root, _xmouse);
}
_x、_y、_rotation、_xscale、_yscale、_height、_width、_alpha 和 _visible 属性都受影片剪辑的父级变形的影响,并对影片剪辑和该剪辑的所有子级加以变形。_focusrect、_highquality、_quality 和 _soundbuftime 属性是全局属性;它们只属于级别 0 主时间轴。所有其它属性都属于每个影片剪辑或加载的级别。
有关影片剪辑属性的列表,请参见MovieClip 类的属性概要。
![]() ![]() | |