К курсору в библиотеке добавил класс Cursor

Код AS3:
package
{
import flash.display;
import flash.display.*;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.ui.Mouse;
public class Cursor extends MovieClip
{
/* * * * * * * * * *
* *
* @author wolsh *
* *
\* * * * * * * * * */
public function Cursor()
{
addEventListener(Event.ADDED_TO_STAGE, init);
addEventListener(Event.REMOVED_FROM_STAGE, remove);
trace(stage.stageHeight , stage.stageWidth)// ошибка
}
private function init(event:Event):void
{
this.removeEventListener(Event.ADDED_TO_STAGE, init);
stage.addEventListener(Event.ADDED, onTop);
stage.addEventListener(MouseEvent.MOUSE_MOVE, onMove);
Mouse.hide();
this.mouseEnabled = false;
this.x = stage.mouseX;
this.y = stage.mouseY;
onTop();
}
private function remove(evt:Event):void
{
this.removeEventListener(Event.REMOVED_FROM_STAGE, remove);
stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
stage.removeEventListener(Event.ADDED, onTop);
Mouse.show();
}
private function onMove(event:MouseEvent):void
{
this.x = event.stageX;
this.y = event.stageY;
event.updateAfterEvent();
}
public function onTop(event:Event = null):void
{
if (stage.getChildIndex(this) != stage.numChildren - 1)
{
stage.setChildIndex(this, stage.numChildren - 1);
}
Mouse.hide();
}
}
}
Но при обращении к stage.stageHeight или stage.stageWidth вылазит ошибка
Цитата:
TypeError: Error #1009: Не удается вызвать свойство или метод со ссылкой на объект "null".
at Cursor()
at tesla::Main()
|
подскажите чё делать?