我希望有一个像静止图像的东西,你可以通过点击按钮移动 - 具有“弹跳”效果。移动到特定位置的按钮很好,但是允许您在特定限制内自由移动的按钮更好。
我在Actionscript 1.0中有一个脚本,我在很久以前找到了它,但我不知道如何更新它为3.0(也没有一个教程解释任何类似的效果)。
可移动MovieClip的脚本:
onClipEvent (load) {
moving = 0;
x = 0;
rebote = 0;
section_actual = 1;
section_new = 1;
friction = 0.9;
}
onClipEvent (enterFrame) {
if (moving == 1)
{
if (cambio == 1)
{
if (section_actual-section_new<0)
{
accel = -2;
}
else
{
accel = 2;
}
}
cambio = 0;
section_actual = section_new;
if (accel == -2)
{
if (_x+xvel<=x)
{
xvel = -xvel;
_x = x;
xvel += accel;
xvel *= friction;
rebote = 1;
}
else
{
_x += xvel;
xvel += accel;
xvel *= friction;
}
}
if (accel == 2)
{
if (_x+xvel>=x)
{
xvel = -xvel;
_x = x;
xvel += accel;
xvel *= friction;
rebote = 1;
}
else
{
_x += xvel;
xvel += accel;
xvel *= friction;
}
}
}
}
一个按钮的脚本:
on (release) {
tellTarget ("../")
{
moving = 1;
x = -335;
rebote = 0;
section_new = 2;
cambio = 1;
}
}
与问题无关,但仍然需要,我需要更新按钮的功能:
on (release) {
_root.gotoAndStop("TT");
}