我想要一个大的静止图像,您可以通过单击按钮来移动它——具有“弹跳”效果。移动到特定位置的按钮很好,但允许您在特定限制内自由移动的附加按钮更好。
我在很久以前找到的 Actionscript 1.0 中有一个脚本,但我不知道如何为 3.0 更新它(也没有解释任何类似效果的教程)。
可移动电影剪辑的脚本:
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");
}