package com.data
{
import mx.controls.Button;
/**
* 格子数据
**/
public class DataItem extends Button
{
public static const TYPES:Array = [1, 2, 3, 4, 5, 6, 7];
public static const WIDTH:uint = 50;
public static const HEIGHT:uint = 50;
private var _type:int;
private var _px:int;
private var _py:int;
private var _initXY:Boolean;
public function DataItem()
{
super();
this.width = DataItem.WIDTH;
this.height = DataItem.HEIGHT;
this._initXY = false;
select();
}
public function get type():int
{
return _type;
}
public function set type(value:int):void
{
_type = value;
this.label = String(value);
}
public function isSame(item:DataItem):Boolean{
return this._type == item._type;
}
public function get px():int
{
return _px;
}
public function set px(value:int):void
{
_px = value;
}
public function get py():int
{
return _py;
}
public function set py(value:int):void
{
_py = value;
}
public function get initXY():Boolean
{
return _initXY;
}
public function set initXY(value:Boolean):void
{
_initXY = value;
}
public function select(sign:Boolean = false):void{
if(sign){
this.alpha = 1;
}else{
this.alpha = 0.2;
}
}
}
}
-------------------------------------------------------------------------
package com.data
{
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.TimerEvent;
import flash.utils.Timer;
import mx.containers.Panel;
/**L
* 对对碰容器管理
**/
public class DataManager extends Panel
{
private var _data:Array;
private var _rows:uint;
private var _cols:uint;
private var _deletes:Array;
private var _selectItem:DataItem;
private var _timer:Timer;
private var _item1:DataItem;
private var _item2:DataItem;
private var _active:Boolean = false;
private var _unselect:Boolean = false;
public function DataManager(rows:uint, cols:uint)
{
super();
this.layout = "absolute";
_data = new Array();
_rows = rows;
_cols = cols;
_deletes = new Array();
var i:uint = 0;
var j:uint = 0;
var item:DataItem = null;<