Показать сообщение отдельно
Старый 13.01.2013, 18:03
semenyakinVS вне форума Посмотреть профиль Отправить личное сообщение для semenyakinVS Найти все сообщения от semenyakinVS
  № 3  
Ответить с цитированием
semenyakinVS

Регистрация: Mar 2010
Сообщений: 137
Странно. Вот на таком примере работает:

Код AS3:
var theButton:ButtonWrapper = new ButtonWrapper(new IncreaseButtonMovie());
theButton.x = 100.0;
theButton.y = 100.0;
this.addChild(theButton);
 
var theCursor:MovieClip = new MovieClip();
theCursor.graphics.lineStyle(1.0, 0x00FF00, 1.0);
theCursor.graphics.beginFill(0x0000FF, 0.5);
theCursor.graphics.drawCircle(0.0, 0.0, 50.0);
theCursor.graphics.endFill();
 
theCursor.mouseChildren = false;
theCursor.mouseEnabled = false;
 
this.addChild(theCursor);
stage.addEventListener(MouseEvent.MOUSE_MOVE, mouseMoveListener);
function mouseMoveListener(ev:MouseEvent)
{
	theCursor.x = ev.stageX;
	theCursor.y = ev.stageY;
}
А в основном коде - дудки.

Добавлено через 42 секунды
Да, тут buttonWrapper:

Код AS3:
package view.buttons
{
	import flash.display.MovieClip;
	import flash.events.MouseEvent;
	import flash.events.Event;
 
	public class ButtonWrapper extends MovieClip
	{
		public static const ACTIOIN_EVENT:String = "ActionEvent";
 
		private var _graphic:MovieClip;
 
		public function ButtonWrapper(aGraphic:MovieClip)
		{
			_graphic = aGraphic;			
			this.addChild(aGraphic);
 
			// Animation initialization
			_graphic.gotoAndStop(1);
 
			initEvents();
		}
 
		private function pressed()
		{			
			var theEvent:Event = new Event(ACTIOIN_EVENT);
			this.dispatchEvent(theEvent);
		}
 
		// ***************
		// Initializations
		// ***************
		private function initEvents()
		{
			_graphic.addEventListener(MouseEvent.ROLL_OUT, rollOutHandle);
			_graphic.addEventListener(MouseEvent.ROLL_OVER, rollOverHandle);
			_graphic.addEventListener(MouseEvent.MOUSE_DOWN, mouseDownHandle);
			_graphic.addEventListener(MouseEvent.MOUSE_UP, mouseUpHandle);
		}
 
		// ********
		// Handlers
		// ********
		private function rollOutHandle(anEvent:MouseEvent)
		{
			_graphic.gotoAndStop(1);
		}
 
		private function rollOverHandle(anEvent:MouseEvent)
		{
			_graphic.gotoAndStop(2);
		}
 
		private function mouseDownHandle(anEvent:MouseEvent)
		{
			this.pressed();
			_graphic.gotoAndStop(3);
		}
 
		private function mouseUpHandle(anEvent:MouseEvent)
		{
			_graphic.gotoAndStop(2);
		}
	}
}