Hey guys,
So I’ve been trying to move the stage’s X and Y position and keep on getting this error:
Error: Error #2071: The Stage class does not implement this property or method.
at Error$/throwError()
at flash.display::Stage/set y()
at Main/scroll()
I am using a document class, here it is:
package
{
import flash.display.MovieClip;
import flash.events.Event;
import flash.events.MouseEvent;
public class Main extends MovieClip
{
private var WIDTH:Number;
private var HEIGHT:Number;
private const PERCENT:Number = 0.05;
private const SCROLL_X:Number = 5;
private const SCROLL_Y:Number = 5;
public function Main()
{
WIDTH = stage.stageWidth;
HEIGHT = stage.stageHeight;
this.addEventListener(Event.ENTER_FRAME, scroll, false, 0, true);
}
public function scroll(e:Event)
{
if (stage.mouseX > (WIDTH - (WIDTH * PERCENT)) )
stage.x -= SCROLL_X;
else if (stage.mouseX < (WIDTH * PERCENT) )
stage.x += SCROLL_X;
if (stage.mouseY > (HEIGHT - (HEIGHT * PERCENT)) )
stage.y -= SCROLL_Y;
else if (stage.mouseY < (HEIGHT * PERCENT) )
stage.y += SCROLL_Y;
}
}
}
As for why I’m trying to move the stage, I have a movieclip which moves according to keyboard input and i want the stage/Background to always center on him.
Any ideas how to fix this?
Thanks
-Fox