Показать сообщение отдельно
Старый 06.02.2017, 23:53
Nooob вне форума Посмотреть профиль Отправить личное сообщение для Nooob Найти все сообщения от Nooob
  № 52  
Ответить с цитированием
Nooob
 
Аватар для Nooob

Регистрация: Mar 2007
Сообщений: 319
Код AS3:
public class MyPlayerElementClass extends MyClass
{
    public var playerElement:int;
    public function MyPlayerElementClass(playerElement:int)
    {
         super();
         this.playerElement = playerElement;
    }
}
 
function drawField(playerElement:int)
{
     var cell:MyPlayerElementClass = new MyPlayerElementClass(playerElement);
     cell.addEventListener(MouseEvent.CLICK, onCellClick);
}
 
function onCellClick(event:MouseEvent)
{
     var cell:MyPlayerElementClass = event.currentTarget as MyPlayerElementClass;
     trace(cell.playerElement);
}
Код AS3:
	var dictionary:Dictionary = new Dictionary();
	function drawField(playerElement:int)
	{
		var cell:MyClass = new MyClass();
		dictionary[cell] = playerElement;
		cell.addEventListener(MouseEvent.CLICK, onCellClick);
	}
	function onCellClick(event:MouseEvent)
	{
		trace(dictionary[event.currentTarget]);
	}