在我的Background.as中,我有以下代码来进行背景滚动:
package{
//Defining the class
import flash.display.MovieClip;
import flash.events.Event;
public class Background extends MovieClip{
function Background()
{
//Executes the enterFrame function
addEventListener("enterFrame", enterFrame);
}
function enterFrame(e:Event)
{
this.x -= 1;
}
}
}
背景是一个将AS Linkage设置为Background
的Moveclip。我想知道如何将背景重置回Main.as
答案 0 :(得分:0)
您可以在应用任何更改之前简单地存储原始位置,并参考:
public class Background extends MovieClip
{
private var _startPosition:Point;
public function Background()
{
_startPosition = new Point(x, y);
addEventListener(Event.ENTER_FRAME, _enterFrame);
}
private function _enterFrame(e:Event):void
{
x -= 1;
}
public function reset():void
{
x = _startPosition.x;
y = _startPosition.y;
}
}