1.选中要跟随的东西,按F8转换成影片剪辑,然后右键影片剪辑,选动作,在动作内加代码:
startDrag("stars",true);
2.上述影片剪辑做好后,选中,点属性,在左边命名一个实例名称,然后选正帧,右键--》动作,在动作内写代码:
mc.onEnterFrame
=
function()
{
mc._x
+=
(_xmouse-mc._x)/5;
mc._y
+=
(_ymouse-mc._y)/5;
};
画一个图形,如五角星,右击-转换为元件-影片剪辑,打开属性面板,设置实例名称为“star1”,再设置这一帧的帧动作为:
star1.onEnterFrame
=
function()
{
this._x
+=
(_root._xmouse-this._x)/5;
this._y
+=
(_root._ymouse-this._y)/5;
};
for
(var
i
=
2;
i<=7;
i++)
{
duplicateMovieClip("star1",
"star"+i,
i);
_root["star"+i]._alpha
=
100-i*10;
_root["star"+i]._xscale
=
100-i*10;
_root["star"+i]._yscale
=
100-i*10;
_root["star"+i].onEnterFrame
=
function()
{
this._x
+=
(_root["star"+(this._name.substring(4)-1)]._x-this._x)/5;
this._y
+=
(_root["star"+(this._name.substring(4)-1)]._y-this._y)/5;
};
}