Показать сообщение отдельно
Старый 19.07.2010, 18:13
Maraekb вне форума Посмотреть профиль Отправить личное сообщение для Maraekb Найти все сообщения от Maraekb
  № 1  
Ответить с цитированием
Maraekb
 
Аватар для Maraekb

Регистрация: Mar 2009
Адрес: Екатеринбург
Сообщений: 30
Отправить сообщение для Maraekb с помощью ICQ
По умолчанию Обращение к stage.stage*

К курсору в библиотеке добавил класс 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()
подскажите чё делать?