按照以下步骤建立文档:
1。制作滑动的矩形,实例名为:mask
在帧上加入代码:
onClipEvent (load)
{
_root.newposition3 = "null";
}
onClipEvent (enterFrame)
{
current = getProperty(_root.mask, _y);
if (_root.newposition3 < current)
{
distance = current - _root.newposition3;
setProperty("_root.mask", _y, current - distance * 0.200000);
} // end if
if (_root.newposition3 > current)
{
distance = _root.newposition3 - current;
setProperty("_root.mask", _x, current + distance * 0.200000);
} // end if
}
2。加新层,绘制一个稍小的矩形,实例名为:bar,置于mask层上面,添加代码:
onClipEvent (load)
{
_root.newposition2 = "null";
}
onClipEvent (enterFrame)
{
current = getProperty(_root.bar, _y);
if (_root.newposition2 < current)
{
distance = current - _root.newposition2;
setProperty("_root.bar", _y, current - distance * 0.300000);
} // end if
if (_root.newposition2 > current)
{
distance = _root.newposition2 - current;
setProperty("_root.bar", _y, current + distance * 0.300000);
} // end if
}
------------------------------------------------------------------------------------------------------
顺便说下flash里图片随鼠标移动的原理:
例如在当前层上放一个影片剪辑,名称为overBar,那么它跟随鼠标移动的代码就是:
this.overBar._x = this._xmouse;
this.overBar._y = this._ymouse;
this.onEnterFrame = function ()
{
this.overBar._x = this._xmouse;
this.overBar._y = this._ymouse;
};