In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

Union Platform avatar chat forked from: colin challenge for professionals

http://asmple.com/unionplatform/002/
をフルスクラッチで出来るとこだけ移植しましたよー。
ユーザIDで自動ログインに変えました。
@author naoto koshikawa
/**
 * Copyright naoto5959 ( http://wonderfl.net/user/naoto5959 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/q1jB
 */

// forked from checkmate's colin challenge for professionals
package  
{
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.KeyboardEvent;
	import flash.events.MouseEvent;
	import flash.events.TextEvent;
	import flash.system.Capabilities;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	import flash.ui.Keyboard;
	import flash.ui.Mouse;
	import net.user1.reactor.Attribute;
	import net.user1.reactor.IClient;
	import net.user1.reactor.Reactor;
	import net.user1.reactor.ReactorEvent;
	import net.user1.reactor.Room;
	import net.user1.reactor.RoomEvent;
	
	[SWF(width = "465", height = "465", backgroundColor = "0x111111", frameRate = "30")]
	/**
	 * http://asmple.com/unionplatform/002/
	 * をフルスクラッチで出来るとこだけ移植しましたよー。
	 * ユーザIDで自動ログインに変えました。
	 * @author naoto koshikawa
	 */
	public class ColinPro extends Sprite
	{
		//--------------------------------------------------------------
		//  properties
		//--------------------------------------------------------------
		//----------------------
		//  static properties
		//----------------------
		/**
		 * server host
		 */
		private static const HOST:String = "tryunion.com";
		
		/**
		 * server port
		 */
		private static const PORT:Number = 9100;
		
		/**
		 * room name
		 */
		private static const ROOM_NAME:String = "naoto5959room";
		
		public static const STAGE_WIDTH:Number = 465;
		public static const STAGE_HEIGHT:Number = 465;
		public static const FIELD_WIDTH:Number = STAGE_WIDTH - 32;
		public static const FIELD_HEIGHT:Number = STAGE_HEIGHT - 46;
		
		
		//----------------------
		//  private properties
		//----------------------
		/**
		 * client data
		 */
		private var _clientData:ClientData;
		
		/**
		 * client data list
		 */
		private var _clientDataList:Object = { };
		
		/**
		 * reactor
		 */
		private var _reactor:Reactor;
		
		/**
		 * room
		 */
		private var _room:Room;
		
		/**
		 * indicate if during input or not 
		 */
		private var _isDuringInput:Boolean;
		
		//----------------------
		//  DisplayObject
		//----------------------
		private var _txtName:TextField;
		
		private var _btnJoin:Sprite;
		
		private var _txtComment:TextField;
		
		private var _btnComment:Sprite;
		
		private var _btnColor:Sprite;
		
		private var _colorPalette:ColorPalette;
		
		private var _field:Sprite;
		
		//--------------------------------------------------------------
		//  method
		//--------------------------------------------------------------
		/**
		 * constructor
		 */
		public function ColinPro() 
		{
			_clientData = new ClientData();
			_clientData.color = 0x777777 + 0x888888 * Math.random();
			_clientData.x = Math.floor(Math.random() * FIELD_WIDTH) + 1;
			_clientData.y = Math.floor(Math.random() * FIELD_HEIGHT) + 1;
			
			_reactor = new Reactor(null, Capabilities.playerType == "External");
			_reactor.addEventListener(ReactorEvent.READY, _reactor_readyHandler);
//			_reactor.addEventListener(ReactorEvent.CLOSE, _reactor_closeHandler);
			_reactor.connect(HOST, PORT);
		}
		

		
		/**
		 * join to Union Server
		 */
		private function join():void
		{
			_clientData_changeHandler();
			var client:IClient = _reactor.getClientManager().self();
			_clientDataList[client.getClientID()] = _clientData;
			
			_room = _reactor.getRoomManager().createRoom(ROOM_NAME);
			_room.addEventListener(RoomEvent.JOIN, _room_joinHandler);
			_room.addEventListener(RoomEvent.SYNCHRONIZE, _room_synchronizeHandler);
			_room.addEventListener(RoomEvent.ADD_CLIENT, _room_addClientHandler);
			_room.addEventListener(RoomEvent.REMOVE_CLIENT, _room_removeClientHandler);
			_room.addEventListener(RoomEvent.UPDATE_CLIENT_ATTRIBUTE, _room_updateClientAttributeHandler);
			_room.join();
		}
		
		/**
		 * add client to current room
		 * @param	client
		 */
		private function addClient(client:IClient):void
		{
			var clientData:ClientData;
			if (_clientDataList.hasOwnProperty(client.getClientID()))
			{
				clientData = _clientDataList[client.getClientID()];
			}
			else
			{
				clientData = new ClientData(client);
				_clientDataList[client.getClientID()] = clientData;
			}
			
			if (_field.getChildByName(client.getClientID())) return;
			
			var avatar:Avatar = new Avatar(clientData);
			avatar.name = client.getClientID();
			_field.addChild(avatar);
		}
		
		/**
		 * remove client from current room
		 * @param	client
		 */
		private function removeClient(client:IClient):void
		{
			delete _clientDataList[client.getClientID()];
			
			_field.removeChild(_field.getChildByName(client.getClientID()));
		}
		
		/**
		 * update client data
		 * @param	event
		 */
		private function updateClient(client:IClient, changeAttr:Attribute):void
		{
			var clientData:ClientData = ClientData(_clientDataList[client.getClientID()]);
			
			if (!clientData) 
			{
				addClient(client);
				clientData = ClientData(_clientDataList[client.getClientID()]);
			}
			
			if (changeAttr.name == "clientname" || changeAttr.name == "comment")
			{
				clientData[changeAttr.name] = decodeURI(changeAttr.value);
			}
			else
			{
				clientData[changeAttr.name] = changeAttr.value;
			}
		}
		
		//----------------------
		//  event handler
		//----------------------
		/**
		 * handler of ReactorEvent.READY
		 * @param	event
		 */
		private function _reactor_readyHandler(event:ReactorEvent):void
		{
			buildUI();
			_txtName.text = _reactor.getClientManager().self().getClientID();
//			_btnJoin.addEventListener(MouseEvent.CLICK, _btnJoin_clickHandler);
			_btnJoin_clickHandler(null);
		}
		
		/**
		 * handler of MouseEvent.CLICK
		 * @param	event
		 */
		private function _btnJoin_clickHandler(event:MouseEvent):void
		{
			if (_txtName.text.length < 1) return;
			_clientData.clientname = _txtName.text;
			_btnJoin.removeEventListener(MouseEvent.CLICK, _btnJoin_clickHandler);
			join();
		}
		
		/**
		 * handler of RoomEvent.JOIN
		 * @private
		 */
		private function _room_joinHandler(event:RoomEvent):void
		{
			_btnJoin.removeEventListener(MouseEvent.CLICK, _btnJoin_clickHandler);
			removeChild(_btnJoin);
			removeChild(_txtName);
			
			addChild(_btnColor);
			addChild(_colorPalette);
			addChild(_txtComment);
			addChild(_btnComment);
			addChild(_field);
			
			_clientData.addEventListener(Event.CHANGE, _clientData_changeHandler);
			_field.addEventListener(MouseEvent.CLICK, _field_clickHandler);
			_btnColor.addEventListener(MouseEvent.CLICK, _btnColor_clickHandler);
			_btnComment.addEventListener(MouseEvent.CLICK, _btnComment_clickHandler);
			_txtComment.addEventListener(KeyboardEvent.KEY_UP, _txtComment_keyboardUpHandler);
			_txtComment.addEventListener(TextEvent.TEXT_INPUT, _txtComment_textInputHandler);
		}
		
		/**
		 * handler of RoomEvent.SYNCHRONIZE
		 * @private
		 */
		private function _room_synchronizeHandler(event:RoomEvent):void
		{
			for each(var client:IClient in _room.getClients())
			{
				addClient(client);
			}
		}
		
		/**
		 * handler of RoomEvent.ADD_CLIENT
		 * @private
		 */
		private function _room_addClientHandler(event:RoomEvent):void
		{
			addClient(event.getClient());
		}
		
		/**
		 * handler of RoomEvent.REMOVE_CLIENT
		 * @private
		 */
		private function _room_removeClientHandler(event:RoomEvent):void
		{
			removeClient(event.getClient());
		}
		
		/**
		 * handler of RoomEvent.UPDATE_CLIENT_ATTRIBUTE
		 * @private
		 */
		private function _room_updateClientAttributeHandler(event:RoomEvent):void
		{
			
			var changedAttr:Attribute = event.getChangedAttr();
			switch (changedAttr.name)
			{
				case "x":
				case "y":
				case "color":
				case "clientname":
				case "comment":
				{
					updateClient(event.getClient(), changedAttr);
				}
			}
		}
		
		/**
		 * handler of Event.CHANGE
		 * @param	event
		 */
		private function _clientData_changeHandler(event:Event = null):void
		{
			var client:IClient = _reactor.getClientManager().self();
			client.setAttribute("x", String(_clientData.x));
			client.setAttribute("y", String(_clientData.y));
			client.setAttribute("color", String(_clientData.color));
			client.setAttribute("clientname", String(encodeURI(_clientData.clientname)));
			client.setAttribute("comment", String(encodeURI(_clientData.comment)));
		}
		
		/**
		 * handler of MouseEvent.CLICK
		 * @param	event
		 */
		private function _field_clickHandler(event:MouseEvent):void
		{
			_clientData.x = _field.mouseX;
			_clientData.y = _field.mouseY;
		}
		
		/**
		 * handler of MouseEvent.CLICK
		 * @param	event
		 */
		private function _btnColor_clickHandler(event:MouseEvent):void
		{
			addChild(_colorPalette);
			_colorPalette.x = mouseX;
			_colorPalette.y = mouseY - _colorPalette.height;
			_colorPalette.visible = true;
			
			_btnColor.removeEventListener(MouseEvent.CLICK, _btnColor_clickHandler);
			_colorPalette.addEventListener(MouseEvent.CLICK, _colorPalette_clickHandler);
		}
		
		/**
		 * handler of MouseEvent.CLICK
		 * @param	event
		 */
		private function _btnComment_clickHandler(event:MouseEvent = null):void
		{
			if (!_txtComment.text) return;
			_clientData.comment = _txtComment.text;
			_txtComment.text = "";
		}
		
		/**
		 * handler of KeyboardEvent.KEY_UP
		 * @param	event
		 */
		private function _txtComment_keyboardUpHandler(event:KeyboardEvent):void
		{
			if (event.keyCode == Keyboard.ENTER && !_isDuringInput)
				_btnComment_clickHandler();
			_isDuringInput = false;
		}
		
		/**
		 * handler of TextEvent.TEXT_INPUT
		 * @param	event
		 */
		private function _txtComment_textInputHandler(event:TextEvent):void
		{
			_isDuringInput= true;
		}
		
		
		/**
		 * hadler of MouseEvent.CLICK
		 *  dispatched from _colorPalette
		 * @param	event
		 */
		private function _colorPalette_clickHandler(event:MouseEvent):void
		{
			_colorPalette.removeEventListener(MouseEvent.CLICK, _colorPalette_clickHandler);
			
			var color32:uint = _colorPalette.bitmapData.getPixel32(_colorPalette.mouseX, _colorPalette.mouseY);
			var color24:uint = color32 & 0x00FFFFFF;
			var alpha:uint = (color32 >> 24) & 0xFF;
			if (!alpha) return;
			
			_btnColor.graphics.clear();
			_btnColor.graphics.beginFill(color24);
			_btnColor.graphics.drawRect(0, 0, 16, 16);
			_colorPalette.visible = false;
			
			// change data's color
			_clientData.color = color24;
			_btnColor.addEventListener(MouseEvent.CLICK, _btnColor_clickHandler);
		}
		
		//----------------------
		//  build UI method
		//----------------------
		/**
		 * build UI
		 */
		private function buildUI():void
		{
			// login name
			_txtName = new TextField();
			_txtName.defaultTextFormat = new TextFormat("_等幅", 12, 0xFFFFFF);
			_txtName.type = TextFieldType.INPUT;
			_txtName.maxChars = 10;
			_txtName.width = 100;
			_txtName.height = 14;
			_txtName.border = true;
			_txtName.borderColor = 0xFFFFFF;
			_txtName.x = (STAGE_WIDTH - _txtName.width) / 2;
			_txtName.y = (STAGE_HEIGHT - _txtName.height) / 2;
			addChild(_txtName);
			
			// login button
			_btnJoin = new Sprite();
			_btnJoin.graphics.beginFill(0x66CC00);
			_btnJoin.graphics.drawRect(0, 0, 40, 16);
			_btnJoin.mouseChildren = false;
			
			var labelJoin:TextField = new TextField();
			labelJoin.defaultTextFormat = new TextFormat("_等幅", 12, 0xFFFFFF);
			labelJoin.width = labelJoin.height = 0;
			labelJoin.autoSize = TextFieldAutoSize.LEFT;
			labelJoin.text = "join";
			labelJoin.x = 4;
			_btnJoin.addChild(labelJoin);
			_btnJoin.x = _txtName.x + _txtName.width + 10;
			_btnJoin.y = _txtName.y;
			addChild(_btnJoin);
			
			// color button
			_btnColor = new Sprite();
			_btnColor.graphics.beginFill(_clientData.color);
			_btnColor.graphics.drawRect(0, 0, 16, 16);
			_btnColor.x = 2;
			_btnColor.y = STAGE_WIDTH - _btnColor.height - 2;
//			addChild(_btnColor);
			
			// color palette
			_colorPalette = new ColorPalette(ColorGenerator.WEB_SAFE_COLOR);
			_colorPalette.visible = false;
//			addChild(_colorPalette);
			
			// comment input
			_txtComment = new TextField();
			_txtComment.defaultTextFormat = new TextFormat("_等幅", 12, 0xFFFFFF);
			_txtComment.type = TextFieldType.INPUT;
			_txtComment.maxChars = 40;
			_txtComment.width = 400;
			_txtComment.height = 14;
			_txtComment.border = true;
			_txtComment.borderColor = 0xFFFFFF;
			_txtComment.x = _btnColor.x + _btnColor.width + 2;
			_txtComment.y = _btnColor.y;
//			addChild(_txtComment);
			
			// comment button
			_btnComment = new Sprite();
			_btnComment.graphics.beginFill(0x66CC00);
			_btnComment.graphics.drawRect(0, 0, 40, 16);
			_btnComment.mouseChildren = false;
			
			var labelComment:TextField = new TextField();
			labelComment.defaultTextFormat = new TextFormat("_等幅", 12, 0xFFFFFF);
			labelComment.width = labelComment.height = 0;
			labelComment.autoSize = TextFieldAutoSize.LEFT;
			labelComment.text = "send";
			labelComment.x = 4;
			_btnComment.addChild(labelComment);
			_btnComment.x = _txtComment.x + _txtComment.width + 2;
			_btnComment.y = _txtComment.y;
//			addChild(_btnComment);
			
			// field
			_field = new Sprite();
			_field.graphics.beginFill(0xFF000000, 0.0);
			_field.graphics.drawRect(0, 0, STAGE_WIDTH - 32, STAGE_HEIGHT - _txtComment.height - 32);
			_field.x = _field.y = 16;
//			addChild(_field);
		}
	}
}
import caurina.transitions.Tweener;
import flash.display.PixelSnapping;
import flash.events.Event;
import flash.events.EventDispatcher;
import flash.geom.ColorTransform;
import net.user1.reactor.IClient;

class ClientData extends EventDispatcher
{
	private var _x:Number = -100;
	public function get x():Number
	{
		return _x;
	}
	public function set x(value:Number):void
	{
		_x = value;
	}
	
	private var _y:Number = -100;
	public function get y():Number
	{
		return _y;
	}
	public function set y(value:Number):void
	{
		_y = value;
		dispatchEvent(new Event(Event.CHANGE));
	}
	
	private var _color:uint;
	public function get color():uint
	{
		return _color;
	}
	public function set color(value:uint):void
	{
		_color = value;
		dispatchEvent(new Event(Event.CHANGE));
	}
	
	private var _clientname:String = "";
	public function get clientname():String
	{
		return _clientname;
	}
	public function set clientname(value:String):void
	{
		_clientname = value;
		dispatchEvent(new Event(Event.CHANGE));
	}
	
	private var _comment:String = "";
	public function get comment():String
	{
		return _comment;
	}
	public function set comment(value:String):void
	{
		_comment = value;
		dispatchEvent(new Event(Event.CHANGE));
	}
	
	//--------------------------------------------------------------
	//  method
	//--------------------------------------------------------------
	/**
	 * constructor
	 */
	public function ClientData(client:IClient = null):void
	{
		if (client)
		{
			if (client.getAttribute("x") != null)
				x = Number(client.getAttribute("x"));
			if (client.getAttribute("y") != null)
				y = Number(client.getAttribute("y"));
			if (client.getAttribute("color") != null)
				color = Number(client.getAttribute("color"));
			if (client.getAttribute("clientname") != null)
				clientname = String(decodeURI(client.getAttribute("clientname")));
			if (client.getAttribute("comment") != null)
				comment = String(decodeURI(client.getAttribute("comment")));
		}
	}
}


/**
 * Avatar
 */
import flash.display.Sprite;
import flash.text.TextField;
class Avatar extends Sprite
{
	//--------------------------------------------------------------
	//  properties
	//--------------------------------------------------------------
	/**
	 * client data
	 */
	private var _clientData:ClientData;
	
	//----------------------
	//  DisplayObject
	//----------------------
	/**
	 * avatar body
	 */
	private var _avatarBody:AvatarBody;
	
	/**
	 * client name
	 */
	private var _clientName:TextField;
	
	/**
	 * comment balloon
	 */
	private var _balloon:Balloon;
	
	//--------------------------------------------------------------
	//  method
	//--------------------------------------------------------------
	/**
	 * constructor
	 */
	public function Avatar(clientData:ClientData)
	{
		_clientData = clientData;
		_clientData.addEventListener(Event.CHANGE, _clientData_changeHandler);
		
		addChild(_avatarBody = new AvatarBody());
		_avatarBody.x -= 16;
		_avatarBody.y -= 16;
		
		var faceBitmapData:BitmapData = new BitmapData(6, 3, true, 0x00000000);
		faceBitmapData.setPixel32(0, 0, 0xFFFFFFFF);
		faceBitmapData.setPixel32(0, 1, 0xFFFFFFFF);
		faceBitmapData.setPixel32(0, 2, 0xFFFFFFFF);
		faceBitmapData.setPixel32(5, 0, 0xFFFFFFFF);
		faceBitmapData.setPixel32(5, 1, 0xFFFFFFFF);
		faceBitmapData.setPixel32(5, 2, 0xFFFFFFFF);
		var faceBitmap:Bitmap = new Bitmap(faceBitmapData);
		faceBitmap.x = -3;
		faceBitmap.y = -12;
		addChild(faceBitmap);
		
		addChild(_clientName = new TextField());
		_clientName.defaultTextFormat = new TextFormat("_等幅", 12, 0xFFFFFF);
		_clientName.selectable = false;
		_clientName.width = _clientName.height = 0;
		_clientName.autoSize = flash.text.TextFieldAutoSize.LEFT;
		
		addChild(_balloon = new Balloon(_clientData));
		
		x = _clientData.x;
		y = _clientData.y;
		
		_clientData_changeHandler();
	}
	
	/**
	 * arrange balloon position
	 */
	private function arrangeBalloon():void
	{
		var direction:uint = 1;
		_balloon.x = - _balloon.width - _avatarBody.width / 2;
		_balloon.y = - _avatarBody.width;
		if (_clientData.x < ColinPro.FIELD_WIDTH / 2)
		{
			direction = 3;
			_balloon.x = _avatarBody.width / 2;
		}
		_balloon.setMessage(_clientData.comment, direction);
	}
	
	//----------------------
	//  event handler
	//----------------------
	/**
	 * handler of Event.CHANGE
	 * @param	event
	 */
	private function _clientData_changeHandler(event:Event = null):void
	{
		// x, y
		if (x > 0 && y > 0)
		{
			var distance:int = Math.sqrt(Math.pow(_clientData.x - x, 2) + Math.pow(_clientData.y - y, 2));
			Tweener.addTween(this, {
				x: _clientData.x,
				y: _clientData.y,
				time: distance * 0.005, 
				transition: "easeOutCubic",
				onComplete: function():void {
					arrangeBalloon();
				}
			});
		}
		else
		{
			x = _clientData.x;
			y = _clientData.y;
		}
		// color
		var colorTransform:ColorTransform = new ColorTransform();
		colorTransform.color = _clientData.color;
		_avatarBody.transform.colorTransform = colorTransform;
		
		// name
		if (_clientData.clientname) _clientName.text = _clientData.clientname;
		_clientName.x = - _clientName.width / 2;
		_clientName.y = _avatarBody.height / 2;
		
		// comment
		if (_clientData.comment != null)
		{
			arrangeBalloon();
		}
	}
}

/**
 * Avatar Body
 * @author naoto koshikawa
 */
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.events.Event;
class AvatarBody extends Sprite
{
	//--------------------------------------------------------------
	//  properties
	//--------------------------------------------------------------
	//----------------------
	//  static properties
	//----------------------
	public static const WIDTH:Number = 32;
	public static const HEIGHT:Number = 32;
	public static const STATUS1_START_FRAME:uint = 1;
	public static const STATUS1_END_FRAME:uint = 10;
	public static const STATUS2_START_FRAME:uint = 11;
	public static const STATUS2_END_FRAME:uint = 25;
	
	//----------------------
	//  private properties
	//----------------------
	/**
	 * avatar bitmap
	 */
	private var _bitmap1:Bitmap;
	
	private var _bitmapData1:BitmapData;
	
	private var _bitmap2:Bitmap;
	
	private var _bitmapData2:BitmapData;
	
	/**
	 * frame count
	 */
	private var _frame:uint = 0;
	
	//--------------------------------------------------------------
	//  method
	//--------------------------------------------------------------
	public function AvatarBody()
	{
		drawState1();
		drawState2();
		_bitmap1 = new Bitmap(_bitmapData1, PixelSnapping.NEVER);
		_bitmap1.visible = true;
		_bitmap2 = new Bitmap(_bitmapData2, PixelSnapping.NEVER);
		_bitmap2.visible = true;
		addChild(_bitmap1);
		addChild(_bitmap2);
		
		addEventListener(Event.ENTER_FRAME, enterFrameHandler);
	}
	
	//----------------------
	//  event handler
	//----------------------
	/**
	 * handler of this
	 *  dispatched from this
	 * @param event
	 */
	private function enterFrameHandler(event:Event):void
	{
		_frame++;
		if (STATUS1_START_FRAME <= _frame && _frame <= STATUS1_END_FRAME)
		{
			_bitmap1.visible = true;
			_bitmap2.visible = false;
		}
		else if (STATUS2_START_FRAME <= _frame && _frame <= STATUS2_END_FRAME)
		{
			_bitmap1.visible = false;
			_bitmap2.visible = true;
		}
		else
		{
			_frame = 0;
		}
	}
	
	//----------------------
	//  private method
	//----------------------
	/**
	 * draw avatar status 1
	 */
	private function drawState1():void
	{
		_bitmapData1 = new BitmapData(WIDTH, HEIGHT, true, 0x00000000);
		_bitmapData1.setPixel32(9, 15, 4278190080);
		_bitmapData1.setPixel32(9, 16, 4278190080);
		_bitmapData1.setPixel32(9, 17, 4278190080);
		_bitmapData1.setPixel32(9, 18, 4278190080);
		_bitmapData1.setPixel32(9, 19, 4278190080);
		_bitmapData1.setPixel32(10, 1, 4278190080);
		_bitmapData1.setPixel32(10, 2, 4278190080);
		_bitmapData1.setPixel32(10, 3, 4278190080);
		_bitmapData1.setPixel32(10, 4, 4278190080);
		_bitmapData1.setPixel32(10, 5, 4278190080);
		_bitmapData1.setPixel32(10, 6, 4278190080);
		_bitmapData1.setPixel32(10, 7, 4278190080);
		_bitmapData1.setPixel32(10, 8, 4278190080);
		_bitmapData1.setPixel32(10, 9, 4278190080);
		_bitmapData1.setPixel32(10, 10, 4278190080);
		_bitmapData1.setPixel32(11, 1, 4278190080);
		_bitmapData1.setPixel32(11, 2, 4278190080);
		_bitmapData1.setPixel32(11, 3, 4278190080);
		_bitmapData1.setPixel32(11, 4, 4278190080);
		_bitmapData1.setPixel32(11, 5, 4278190080);
		_bitmapData1.setPixel32(11, 6, 4278190080);
		_bitmapData1.setPixel32(11, 7, 4278190080);
		_bitmapData1.setPixel32(11, 8, 4278190080);
		_bitmapData1.setPixel32(11, 9, 4278190080);
		_bitmapData1.setPixel32(11, 10, 4278190080);
		_bitmapData1.setPixel32(11, 12, 4278190080);
		_bitmapData1.setPixel32(11, 13, 4278190080);
		_bitmapData1.setPixel32(11, 14, 4278190080);
		_bitmapData1.setPixel32(11, 15, 4278190080);
		_bitmapData1.setPixel32(11, 16, 4278190080);
		_bitmapData1.setPixel32(11, 17, 4278190080);
		_bitmapData1.setPixel32(11, 18, 4278190080);
		_bitmapData1.setPixel32(11, 19, 4278190080);
		_bitmapData1.setPixel32(11, 20, 4278190080);
		_bitmapData1.setPixel32(11, 21, 4278190080);
		_bitmapData1.setPixel32(11, 22, 4278190080);
		_bitmapData1.setPixel32(11, 23, 4278190080);
		_bitmapData1.setPixel32(12, 1, 4278190080);
		_bitmapData1.setPixel32(12, 2, 4278190080);
		_bitmapData1.setPixel32(12, 3, 4278190080);
		_bitmapData1.setPixel32(12, 4, 4278190080);
		_bitmapData1.setPixel32(12, 5, 4278190080);
		_bitmapData1.setPixel32(12, 6, 4278190080);
		_bitmapData1.setPixel32(12, 7, 4278190080);
		_bitmapData1.setPixel32(12, 8, 4278190080);
		_bitmapData1.setPixel32(12, 9, 4278190080);
		_bitmapData1.setPixel32(12, 10, 4278190080);
		_bitmapData1.setPixel32(12, 12, 4278190080);
		_bitmapData1.setPixel32(12, 13, 4278190080);
		_bitmapData1.setPixel32(12, 14, 4278190080);
		_bitmapData1.setPixel32(12, 15, 4278190080);
		_bitmapData1.setPixel32(12, 16, 4278190080);
		_bitmapData1.setPixel32(12, 17, 4278190080);
		_bitmapData1.setPixel32(12, 18, 4278190080);
		_bitmapData1.setPixel32(12, 19, 4278190080);
		_bitmapData1.setPixel32(12, 20, 4278190080);
		_bitmapData1.setPixel32(12, 21, 4278190080);
		_bitmapData1.setPixel32(12, 22, 4278190080);
		_bitmapData1.setPixel32(12, 23, 4278190080);
		_bitmapData1.setPixel32(13, 1, 4278190080);
		_bitmapData1.setPixel32(13, 2, 4278190080);
		_bitmapData1.setPixel32(13, 3, 4278190080);
		_bitmapData1.setPixel32(13, 4, 4294967295);
		_bitmapData1.setPixel32(13, 5, 4294967295);
		_bitmapData1.setPixel32(13, 6, 4294967295);
		_bitmapData1.setPixel32(13, 7, 4278190080);
		_bitmapData1.setPixel32(13, 8, 4278190080);
		_bitmapData1.setPixel32(13, 9, 4278190080);
		_bitmapData1.setPixel32(13, 10, 4278190080);
		_bitmapData1.setPixel32(13, 12, 4278190080);
		_bitmapData1.setPixel32(13, 13, 4278190080);
		_bitmapData1.setPixel32(13, 14, 4278190080);
		_bitmapData1.setPixel32(13, 15, 4278190080);
		_bitmapData1.setPixel32(13, 16, 4278190080);
		_bitmapData1.setPixel32(13, 17, 4278190080);
		_bitmapData1.setPixel32(13, 18, 4278190080);
		_bitmapData1.setPixel32(13, 19, 4278190080);
		_bitmapData1.setPixel32(13, 20, 4278190080);
		_bitmapData1.setPixel32(13, 21, 4278190080);
		_bitmapData1.setPixel32(13, 22, 4278190080);
		_bitmapData1.setPixel32(13, 23, 4278190080);
		_bitmapData1.setPixel32(13, 25, 4278190080);
		_bitmapData1.setPixel32(13, 26, 4278190080);
		_bitmapData1.setPixel32(13, 27, 4278190080);
		_bitmapData1.setPixel32(13, 28, 4278190080);
		_bitmapData1.setPixel32(13, 29, 4278190080);
		_bitmapData1.setPixel32(13, 30, 4278190080);
		_bitmapData1.setPixel32(14, 1, 4278190080);
		_bitmapData1.setPixel32(14, 2, 4278190080);
		_bitmapData1.setPixel32(14, 3, 4278190080);
		_bitmapData1.setPixel32(14, 4, 4278190080);
		_bitmapData1.setPixel32(14, 5, 4278190080);
		_bitmapData1.setPixel32(14, 6, 4278190080);
		_bitmapData1.setPixel32(14, 7, 4278190080);
		_bitmapData1.setPixel32(14, 8, 4278190080);
		_bitmapData1.setPixel32(14, 9, 4278190080);
		_bitmapData1.setPixel32(14, 10, 4278190080);
		_bitmapData1.setPixel32(14, 12, 4278190080);
		_bitmapData1.setPixel32(14, 13, 4278190080);
		_bitmapData1.setPixel32(14, 14, 4278190080);
		_bitmapData1.setPixel32(14, 15, 4278190080);
		_bitmapData1.setPixel32(14, 16, 4278190080);
		_bitmapData1.setPixel32(14, 17, 4278190080);
		_bitmapData1.setPixel32(14, 18, 4278190080);
		_bitmapData1.setPixel32(14, 19, 4278190080);
		_bitmapData1.setPixel32(14, 20, 4278190080);
		_bitmapData1.setPixel32(14, 21, 4278190080);
		_bitmapData1.setPixel32(14, 22, 4278190080);
		_bitmapData1.setPixel32(14, 23, 4278190080);
		_bitmapData1.setPixel32(15, 1, 4278190080);
		_bitmapData1.setPixel32(15, 2, 4278190080);
		_bitmapData1.setPixel32(15, 3, 4278190080);
		_bitmapData1.setPixel32(15, 4, 4278190080);
		_bitmapData1.setPixel32(15, 5, 4278190080);
		_bitmapData1.setPixel32(15, 6, 4278190080);
		_bitmapData1.setPixel32(15, 7, 4278190080);
		_bitmapData1.setPixel32(15, 8, 4278190080);
		_bitmapData1.setPixel32(15, 9, 4278190080);
		_bitmapData1.setPixel32(15, 10, 4278190080);
		_bitmapData1.setPixel32(15, 12, 4278190080);
		_bitmapData1.setPixel32(15, 13, 4278190080);
		_bitmapData1.setPixel32(15, 14, 4278190080);
		_bitmapData1.setPixel32(15, 15, 4278190080);
		_bitmapData1.setPixel32(15, 16, 4278190080);
		_bitmapData1.setPixel32(15, 17, 4278190080);
		_bitmapData1.setPixel32(15, 18, 4278190080);
		_bitmapData1.setPixel32(15, 19, 4278190080);
		_bitmapData1.setPixel32(15, 20, 4278190080);
		_bitmapData1.setPixel32(15, 21, 4278190080);
		_bitmapData1.setPixel32(15, 22, 4278190080);
		_bitmapData1.setPixel32(15, 23, 4278190080);
		_bitmapData1.setPixel32(16, 1, 4278190080);
		_bitmapData1.setPixel32(16, 2, 4278190080);
		_bitmapData1.setPixel32(16, 3, 4278190080);
		_bitmapData1.setPixel32(16, 4, 4278190080);
		_bitmapData1.setPixel32(16, 5, 4278190080);
		_bitmapData1.setPixel32(16, 6, 4278190080);
		_bitmapData1.setPixel32(16, 7, 4278190080);
		_bitmapData1.setPixel32(16, 8, 4278190080);
		_bitmapData1.setPixel32(16, 9, 4278190080);
		_bitmapData1.setPixel32(16, 10, 4278190080);
		_bitmapData1.setPixel32(16, 12, 4278190080);
		_bitmapData1.setPixel32(16, 13, 4278190080);
		_bitmapData1.setPixel32(16, 14, 4278190080);
		_bitmapData1.setPixel32(16, 15, 4278190080);
		_bitmapData1.setPixel32(16, 16, 4278190080);
		_bitmapData1.setPixel32(16, 17, 4278190080);
		_bitmapData1.setPixel32(16, 18, 4278190080);
		_bitmapData1.setPixel32(16, 19, 4278190080);
		_bitmapData1.setPixel32(16, 20, 4278190080);
		_bitmapData1.setPixel32(16, 21, 4278190080);
		_bitmapData1.setPixel32(16, 22, 4278190080);
		_bitmapData1.setPixel32(16, 23, 4278190080);
		_bitmapData1.setPixel32(17, 1, 4278190080);
		_bitmapData1.setPixel32(17, 2, 4278190080);
		_bitmapData1.setPixel32(17, 3, 4278190080);
		_bitmapData1.setPixel32(17, 4, 4278190080);
		_bitmapData1.setPixel32(17, 5, 4278190080);
		_bitmapData1.setPixel32(17, 6, 4278190080);
		_bitmapData1.setPixel32(17, 7, 4278190080);
		_bitmapData1.setPixel32(17, 8, 4278190080);
		_bitmapData1.setPixel32(17, 9, 4278190080);
		_bitmapData1.setPixel32(17, 10, 4278190080);
		_bitmapData1.setPixel32(17, 12, 4278190080);
		_bitmapData1.setPixel32(17, 13, 4278190080);
		_bitmapData1.setPixel32(17, 14, 4278190080);
		_bitmapData1.setPixel32(17, 15, 4278190080);
		_bitmapData1.setPixel32(17, 16, 4278190080);
		_bitmapData1.setPixel32(17, 17, 4278190080);
		_bitmapData1.setPixel32(17, 18, 4278190080);
		_bitmapData1.setPixel32(17, 19, 4278190080);
		_bitmapData1.setPixel32(17, 20, 4278190080);
		_bitmapData1.setPixel32(17, 21, 4278190080);
		_bitmapData1.setPixel32(17, 22, 4278190080);
		_bitmapData1.setPixel32(17, 23, 4278190080);
		_bitmapData1.setPixel32(18, 1, 4278190080);
		_bitmapData1.setPixel32(18, 2, 4278190080);
		_bitmapData1.setPixel32(18, 3, 4278190080);
		_bitmapData1.setPixel32(18, 4, 4294967295);
		_bitmapData1.setPixel32(18, 5, 4294967295);
		_bitmapData1.setPixel32(18, 6, 4294967295);
		_bitmapData1.setPixel32(18, 7, 4278190080);
		_bitmapData1.setPixel32(18, 8, 4278190080);
		_bitmapData1.setPixel32(18, 9, 4278190080);
		_bitmapData1.setPixel32(18, 10, 4278190080);
		_bitmapData1.setPixel32(18, 12, 4278190080);
		_bitmapData1.setPixel32(18, 13, 4278190080);
		_bitmapData1.setPixel32(18, 14, 4278190080);
		_bitmapData1.setPixel32(18, 15, 4278190080);
		_bitmapData1.setPixel32(18, 16, 4278190080);
		_bitmapData1.setPixel32(18, 17, 4278190080);
		_bitmapData1.setPixel32(18, 18, 4278190080);
		_bitmapData1.setPixel32(18, 19, 4278190080);
		_bitmapData1.setPixel32(18, 20, 4278190080);
		_bitmapData1.setPixel32(18, 21, 4278190080);
		_bitmapData1.setPixel32(18, 22, 4278190080);
		_bitmapData1.setPixel32(18, 23, 4278190080);
		_bitmapData1.setPixel32(18, 25, 4278190080);
		_bitmapData1.setPixel32(18, 26, 4278190080);
		_bitmapData1.setPixel32(18, 27, 4278190080);
		_bitmapData1.setPixel32(18, 28, 4278190080);
		_bitmapData1.setPixel32(18, 29, 4278190080);
		_bitmapData1.setPixel32(18, 30, 4278190080);
		_bitmapData1.setPixel32(19, 1, 4278190080);
		_bitmapData1.setPixel32(19, 2, 4278190080);
		_bitmapData1.setPixel32(19, 3, 4278190080);
		_bitmapData1.setPixel32(19, 4, 4278190080);
		_bitmapData1.setPixel32(19, 5, 4278190080);
		_bitmapData1.setPixel32(19, 6, 4278190080);
		_bitmapData1.setPixel32(19, 7, 4278190080);
		_bitmapData1.setPixel32(19, 8, 4278190080);
		_bitmapData1.setPixel32(19, 9, 4278190080);
		_bitmapData1.setPixel32(19, 10, 4278190080);
		_bitmapData1.setPixel32(19, 12, 4278190080);
		_bitmapData1.setPixel32(19, 13, 4278190080);
		_bitmapData1.setPixel32(19, 14, 4278190080);
		_bitmapData1.setPixel32(19, 15, 4278190080);
		_bitmapData1.setPixel32(19, 16, 4278190080);
		_bitmapData1.setPixel32(19, 17, 4278190080);
		_bitmapData1.setPixel32(19, 18, 4278190080);
		_bitmapData1.setPixel32(19, 19, 4278190080);
		_bitmapData1.setPixel32(19, 20, 4278190080);
		_bitmapData1.setPixel32(19, 21, 4278190080);
		_bitmapData1.setPixel32(19, 22, 4278190080);
		_bitmapData1.setPixel32(19, 23, 4278190080);
		_bitmapData1.setPixel32(20, 1, 4278190080);
		_bitmapData1.setPixel32(20, 2, 4278190080);
		_bitmapData1.setPixel32(20, 3, 4278190080);
		_bitmapData1.setPixel32(20, 4, 4278190080);
		_bitmapData1.setPixel32(20, 5, 4278190080);
		_bitmapData1.setPixel32(20, 6, 4278190080);
		_bitmapData1.setPixel32(20, 7, 4278190080);
		_bitmapData1.setPixel32(20, 8, 4278190080);
		_bitmapData1.setPixel32(20, 9, 4278190080);
		_bitmapData1.setPixel32(20, 10, 4278190080);
		_bitmapData1.setPixel32(20, 12, 4278190080);
		_bitmapData1.setPixel32(20, 13, 4278190080);
		_bitmapData1.setPixel32(20, 14, 4278190080);
		_bitmapData1.setPixel32(20, 15, 4278190080);
		_bitmapData1.setPixel32(20, 16, 4278190080);
		_bitmapData1.setPixel32(20, 17, 4278190080);
		_bitmapData1.setPixel32(20, 18, 4278190080);
		_bitmapData1.setPixel32(20, 19, 4278190080);
		_bitmapData1.setPixel32(20, 20, 4278190080);
		_bitmapData1.setPixel32(20, 21, 4278190080);
		_bitmapData1.setPixel32(20, 22, 4278190080);
		_bitmapData1.setPixel32(20, 23, 4278190080);
		_bitmapData1.setPixel32(21, 1, 4278190080);
		_bitmapData1.setPixel32(21, 2, 4278190080);
		_bitmapData1.setPixel32(21, 3, 4278190080);
		_bitmapData1.setPixel32(21, 4, 4278190080);
		_bitmapData1.setPixel32(21, 5, 4278190080);
		_bitmapData1.setPixel32(21, 6, 4278190080);
		_bitmapData1.setPixel32(21, 7, 4278190080);
		_bitmapData1.setPixel32(21, 8, 4278190080);
		_bitmapData1.setPixel32(21, 9, 4278190080);
		_bitmapData1.setPixel32(21, 10, 4278190080);
		_bitmapData1.setPixel32(22, 15, 4278190080);
		_bitmapData1.setPixel32(22, 16, 4278190080);
		_bitmapData1.setPixel32(22, 17, 4278190080);
		_bitmapData1.setPixel32(22, 18, 4278190080);
		_bitmapData1.setPixel32(22, 19, 4278190080);
	}
	
	/**
	 * draw avatar status 2
	 */
	private function drawState2():void
	{
		_bitmapData2 = new BitmapData(WIDTH, HEIGHT, true, 0x00000000);
		_bitmapData2.setPixel32(6, 18, 4278190080);
		_bitmapData2.setPixel32(7, 17, 4278190080);
		_bitmapData2.setPixel32(8, 16, 4278190080);
		_bitmapData2.setPixel32(9, 15, 4278190080);
		_bitmapData2.setPixel32(9, 29, 4278190080);
		_bitmapData2.setPixel32(10, 1, 4278190080);
		_bitmapData2.setPixel32(10, 2, 4278190080);
		_bitmapData2.setPixel32(10, 3, 4278190080);
		_bitmapData2.setPixel32(10, 4, 4278190080);
		_bitmapData2.setPixel32(10, 5, 4278190080);
		_bitmapData2.setPixel32(10, 6, 4278190080);
		_bitmapData2.setPixel32(10, 7, 4278190080);
		_bitmapData2.setPixel32(10, 8, 4278190080);
		_bitmapData2.setPixel32(10, 9, 4278190080);
		_bitmapData2.setPixel32(10, 10, 4278190080);
		_bitmapData2.setPixel32(10, 28, 4278190080);
		_bitmapData2.setPixel32(11, 1, 4278190080);
		_bitmapData2.setPixel32(11, 2, 4278190080);
		_bitmapData2.setPixel32(11, 3, 4278190080);
		_bitmapData2.setPixel32(11, 4, 4278190080);
		_bitmapData2.setPixel32(11, 5, 4278190080);
		_bitmapData2.setPixel32(11, 6, 4278190080);
		_bitmapData2.setPixel32(11, 7, 4278190080);
		_bitmapData2.setPixel32(11, 8, 4278190080);
		_bitmapData2.setPixel32(11, 9, 4278190080);
		_bitmapData2.setPixel32(11, 10, 4278190080);
		_bitmapData2.setPixel32(11, 12, 4278190080);
		_bitmapData2.setPixel32(11, 13, 4278190080);
		_bitmapData2.setPixel32(11, 14, 4278190080);
		_bitmapData2.setPixel32(11, 15, 4278190080);
		_bitmapData2.setPixel32(11, 16, 4278190080);
		_bitmapData2.setPixel32(11, 17, 4278190080);
		_bitmapData2.setPixel32(11, 18, 4278190080);
		_bitmapData2.setPixel32(11, 19, 4278190080);
		_bitmapData2.setPixel32(11, 20, 4278190080);
		_bitmapData2.setPixel32(11, 21, 4278190080);
		_bitmapData2.setPixel32(11, 22, 4278190080);
		_bitmapData2.setPixel32(11, 23, 4278190080);
		_bitmapData2.setPixel32(11, 27, 4278190080);
		_bitmapData2.setPixel32(12, 1, 4278190080);
		_bitmapData2.setPixel32(12, 2, 4278190080);
		_bitmapData2.setPixel32(12, 3, 4278190080);
		_bitmapData2.setPixel32(12, 4, 4278190080);
		_bitmapData2.setPixel32(12, 5, 4278190080);
		_bitmapData2.setPixel32(12, 6, 4278190080);
		_bitmapData2.setPixel32(12, 7, 4278190080);
		_bitmapData2.setPixel32(12, 8, 4278190080);
		_bitmapData2.setPixel32(12, 9, 4278190080);
		_bitmapData2.setPixel32(12, 10, 4278190080);
		_bitmapData2.setPixel32(12, 12, 4278190080);
		_bitmapData2.setPixel32(12, 13, 4278190080);
		_bitmapData2.setPixel32(12, 14, 4278190080);
		_bitmapData2.setPixel32(12, 15, 4278190080);
		_bitmapData2.setPixel32(12, 16, 4278190080);
		_bitmapData2.setPixel32(12, 17, 4278190080);
		_bitmapData2.setPixel32(12, 18, 4278190080);
		_bitmapData2.setPixel32(12, 19, 4278190080);
		_bitmapData2.setPixel32(12, 20, 4278190080);
		_bitmapData2.setPixel32(12, 21, 4278190080);
		_bitmapData2.setPixel32(12, 22, 4278190080);
		_bitmapData2.setPixel32(12, 23, 4278190080);
		_bitmapData2.setPixel32(12, 26, 4278190080);
		_bitmapData2.setPixel32(13, 1, 4278190080);
		_bitmapData2.setPixel32(13, 2, 4278190080);
		_bitmapData2.setPixel32(13, 3, 4278190080);
		_bitmapData2.setPixel32(13, 4, 4294967295);
		_bitmapData2.setPixel32(13, 5, 4294967295);
		_bitmapData2.setPixel32(13, 6, 4294967295);
		_bitmapData2.setPixel32(13, 7, 4278190080);
		_bitmapData2.setPixel32(13, 8, 4278190080);
		_bitmapData2.setPixel32(13, 9, 4278190080);
		_bitmapData2.setPixel32(13, 10, 4278190080);
		_bitmapData2.setPixel32(13, 12, 4278190080);
		_bitmapData2.setPixel32(13, 13, 4278190080);
		_bitmapData2.setPixel32(13, 14, 4278190080);
		_bitmapData2.setPixel32(13, 15, 4278190080);
		_bitmapData2.setPixel32(13, 16, 4278190080);
		_bitmapData2.setPixel32(13, 17, 4278190080);
		_bitmapData2.setPixel32(13, 18, 4278190080);
		_bitmapData2.setPixel32(13, 19, 4278190080);
		_bitmapData2.setPixel32(13, 20, 4278190080);
		_bitmapData2.setPixel32(13, 21, 4278190080);
		_bitmapData2.setPixel32(13, 22, 4278190080);
		_bitmapData2.setPixel32(13, 23, 4278190080);
		_bitmapData2.setPixel32(14, 1, 4278190080);
		_bitmapData2.setPixel32(14, 2, 4278190080);
		_bitmapData2.setPixel32(14, 3, 4278190080);
		_bitmapData2.setPixel32(14, 4, 4278190080);
		_bitmapData2.setPixel32(14, 5, 4278190080);
		_bitmapData2.setPixel32(14, 6, 4278190080);
		_bitmapData2.setPixel32(14, 7, 4278190080);
		_bitmapData2.setPixel32(14, 8, 4278190080);
		_bitmapData2.setPixel32(14, 9, 4278190080);
		_bitmapData2.setPixel32(14, 10, 4278190080);
		_bitmapData2.setPixel32(14, 12, 4278190080);
		_bitmapData2.setPixel32(14, 13, 4278190080);
		_bitmapData2.setPixel32(14, 14, 4278190080);
		_bitmapData2.setPixel32(14, 15, 4278190080);
		_bitmapData2.setPixel32(14, 16, 4278190080);
		_bitmapData2.setPixel32(14, 17, 4278190080);
		_bitmapData2.setPixel32(14, 18, 4278190080);
		_bitmapData2.setPixel32(14, 19, 4278190080);
		_bitmapData2.setPixel32(14, 20, 4278190080);
		_bitmapData2.setPixel32(14, 21, 4278190080);
		_bitmapData2.setPixel32(14, 22, 4278190080);
		_bitmapData2.setPixel32(14, 23, 4278190080);
		_bitmapData2.setPixel32(15, 1, 4278190080);
		_bitmapData2.setPixel32(15, 2, 4278190080);
		_bitmapData2.setPixel32(15, 3, 4278190080);
		_bitmapData2.setPixel32(15, 4, 4278190080);
		_bitmapData2.setPixel32(15, 5, 4278190080);
		_bitmapData2.setPixel32(15, 6, 4278190080);
		_bitmapData2.setPixel32(15, 7, 4278190080);
		_bitmapData2.setPixel32(15, 8, 4278190080);
		_bitmapData2.setPixel32(15, 9, 4278190080);
		_bitmapData2.setPixel32(15, 10, 4278190080);
		_bitmapData2.setPixel32(15, 12, 4278190080);
		_bitmapData2.setPixel32(15, 13, 4278190080);
		_bitmapData2.setPixel32(15, 14, 4278190080);
		_bitmapData2.setPixel32(15, 15, 4278190080);
		_bitmapData2.setPixel32(15, 16, 4278190080);
		_bitmapData2.setPixel32(15, 17, 4278190080);
		_bitmapData2.setPixel32(15, 18, 4278190080);
		_bitmapData2.setPixel32(15, 19, 4278190080);
		_bitmapData2.setPixel32(15, 20, 4278190080);
		_bitmapData2.setPixel32(15, 21, 4278190080);
		_bitmapData2.setPixel32(15, 22, 4278190080);
		_bitmapData2.setPixel32(15, 23, 4278190080);
		_bitmapData2.setPixel32(16, 1, 4278190080);
		_bitmapData2.setPixel32(16, 2, 4278190080);
		_bitmapData2.setPixel32(16, 3, 4278190080);
		_bitmapData2.setPixel32(16, 4, 4278190080);
		_bitmapData2.setPixel32(16, 5, 4278190080);
		_bitmapData2.setPixel32(16, 6, 4278190080);
		_bitmapData2.setPixel32(16, 7, 4278190080);
		_bitmapData2.setPixel32(16, 8, 4278190080);
		_bitmapData2.setPixel32(16, 9, 4278190080);
		_bitmapData2.setPixel32(16, 10, 4278190080);
		_bitmapData2.setPixel32(16, 12, 4278190080);
		_bitmapData2.setPixel32(16, 13, 4278190080);
		_bitmapData2.setPixel32(16, 14, 4278190080);
		_bitmapData2.setPixel32(16, 15, 4278190080);
		_bitmapData2.setPixel32(16, 16, 4278190080);
		_bitmapData2.setPixel32(16, 17, 4278190080);
		_bitmapData2.setPixel32(16, 18, 4278190080);
		_bitmapData2.setPixel32(16, 19, 4278190080);
		_bitmapData2.setPixel32(16, 20, 4278190080);
		_bitmapData2.setPixel32(16, 21, 4278190080);
		_bitmapData2.setPixel32(16, 22, 4278190080);
		_bitmapData2.setPixel32(16, 23, 4278190080);
		_bitmapData2.setPixel32(17, 1, 4278190080);
		_bitmapData2.setPixel32(17, 2, 4278190080);
		_bitmapData2.setPixel32(17, 3, 4278190080);
		_bitmapData2.setPixel32(17, 4, 4278190080);
		_bitmapData2.setPixel32(17, 5, 4278190080);
		_bitmapData2.setPixel32(17, 6, 4278190080);
		_bitmapData2.setPixel32(17, 7, 4278190080);
		_bitmapData2.setPixel32(17, 8, 4278190080);
		_bitmapData2.setPixel32(17, 9, 4278190080);
		_bitmapData2.setPixel32(17, 10, 4278190080);
		_bitmapData2.setPixel32(17, 12, 4278190080);
		_bitmapData2.setPixel32(17, 13, 4278190080);
		_bitmapData2.setPixel32(17, 14, 4278190080);
		_bitmapData2.setPixel32(17, 15, 4278190080);
		_bitmapData2.setPixel32(17, 16, 4278190080);
		_bitmapData2.setPixel32(17, 17, 4278190080);
		_bitmapData2.setPixel32(17, 18, 4278190080);
		_bitmapData2.setPixel32(17, 19, 4278190080);
		_bitmapData2.setPixel32(17, 20, 4278190080);
		_bitmapData2.setPixel32(17, 21, 4278190080);
		_bitmapData2.setPixel32(17, 22, 4278190080);
		_bitmapData2.setPixel32(17, 23, 4278190080);
		_bitmapData2.setPixel32(18, 1, 4278190080);
		_bitmapData2.setPixel32(18, 2, 4278190080);
		_bitmapData2.setPixel32(18, 3, 4278190080);
		_bitmapData2.setPixel32(18, 4, 4294967295);
		_bitmapData2.setPixel32(18, 5, 4294967295);
		_bitmapData2.setPixel32(18, 6, 4294967295);
		_bitmapData2.setPixel32(18, 7, 4278190080);
		_bitmapData2.setPixel32(18, 8, 4278190080);
		_bitmapData2.setPixel32(18, 9, 4278190080);
		_bitmapData2.setPixel32(18, 10, 4278190080);
		_bitmapData2.setPixel32(18, 12, 4278190080);
		_bitmapData2.setPixel32(18, 13, 4278190080);
		_bitmapData2.setPixel32(18, 14, 4278190080);
		_bitmapData2.setPixel32(18, 15, 4278190080);
		_bitmapData2.setPixel32(18, 16, 4278190080);
		_bitmapData2.setPixel32(18, 17, 4278190080);
		_bitmapData2.setPixel32(18, 18, 4278190080);
		_bitmapData2.setPixel32(18, 19, 4278190080);
		_bitmapData2.setPixel32(18, 20, 4278190080);
		_bitmapData2.setPixel32(18, 21, 4278190080);
		_bitmapData2.setPixel32(18, 22, 4278190080);
		_bitmapData2.setPixel32(18, 23, 4278190080);
		_bitmapData2.setPixel32(19, 1, 4278190080);
		_bitmapData2.setPixel32(19, 2, 4278190080);
		_bitmapData2.setPixel32(19, 3, 4278190080);
		_bitmapData2.setPixel32(19, 4, 4278190080);
		_bitmapData2.setPixel32(19, 5, 4278190080);
		_bitmapData2.setPixel32(19, 6, 4278190080);
		_bitmapData2.setPixel32(19, 7, 4278190080);
		_bitmapData2.setPixel32(19, 8, 4278190080);
		_bitmapData2.setPixel32(19, 9, 4278190080);
		_bitmapData2.setPixel32(19, 10, 4278190080);
		_bitmapData2.setPixel32(19, 12, 4278190080);
		_bitmapData2.setPixel32(19, 13, 4278190080);
		_bitmapData2.setPixel32(19, 14, 4278190080);
		_bitmapData2.setPixel32(19, 15, 4278190080);
		_bitmapData2.setPixel32(19, 16, 4278190080);
		_bitmapData2.setPixel32(19, 17, 4278190080);
		_bitmapData2.setPixel32(19, 18, 4278190080);
		_bitmapData2.setPixel32(19, 19, 4278190080);
		_bitmapData2.setPixel32(19, 20, 4278190080);
		_bitmapData2.setPixel32(19, 21, 4278190080);
		_bitmapData2.setPixel32(19, 22, 4278190080);
		_bitmapData2.setPixel32(19, 23, 4278190080);
		_bitmapData2.setPixel32(19, 26, 4278190080);
		_bitmapData2.setPixel32(20, 1, 4278190080);
		_bitmapData2.setPixel32(20, 2, 4278190080);
		_bitmapData2.setPixel32(20, 3, 4278190080);
		_bitmapData2.setPixel32(20, 4, 4278190080);
		_bitmapData2.setPixel32(20, 5, 4278190080);
		_bitmapData2.setPixel32(20, 6, 4278190080);
		_bitmapData2.setPixel32(20, 7, 4278190080);
		_bitmapData2.setPixel32(20, 8, 4278190080);
		_bitmapData2.setPixel32(20, 9, 4278190080);
		_bitmapData2.setPixel32(20, 10, 4278190080);
		_bitmapData2.setPixel32(20, 12, 4278190080);
		_bitmapData2.setPixel32(20, 13, 4278190080);
		_bitmapData2.setPixel32(20, 14, 4278190080);
		_bitmapData2.setPixel32(20, 15, 4278190080);
		_bitmapData2.setPixel32(20, 16, 4278190080);
		_bitmapData2.setPixel32(20, 17, 4278190080);
		_bitmapData2.setPixel32(20, 18, 4278190080);
		_bitmapData2.setPixel32(20, 19, 4278190080);
		_bitmapData2.setPixel32(20, 20, 4278190080);
		_bitmapData2.setPixel32(20, 21, 4278190080);
		_bitmapData2.setPixel32(20, 22, 4278190080);
		_bitmapData2.setPixel32(20, 23, 4278190080);
		_bitmapData2.setPixel32(20, 27, 4278190080);
		_bitmapData2.setPixel32(21, 1, 4278190080);
		_bitmapData2.setPixel32(21, 2, 4278190080);
		_bitmapData2.setPixel32(21, 3, 4278190080);
		_bitmapData2.setPixel32(21, 4, 4278190080);
		_bitmapData2.setPixel32(21, 5, 4278190080);
		_bitmapData2.setPixel32(21, 6, 4278190080);
		_bitmapData2.setPixel32(21, 7, 4278190080);
		_bitmapData2.setPixel32(21, 8, 4278190080);
		_bitmapData2.setPixel32(21, 9, 4278190080);
		_bitmapData2.setPixel32(21, 10, 4278190080);
		_bitmapData2.setPixel32(21, 28, 4278190080);
		_bitmapData2.setPixel32(22, 15, 4278190080);
		_bitmapData2.setPixel32(22, 29, 4278190080);
		_bitmapData2.setPixel32(23, 16, 4278190080);
		_bitmapData2.setPixel32(24, 17, 4278190080);
		_bitmapData2.setPixel32(25, 18, 4278190080);
	}
}

/**
 * Balloon
 */

import fl.transitions.easing.Strong;
import fl.transitions.Tween;
import fl.transitions.TweenEvent;
import flash.display.Graphics;
import flash.display.MovieClip;
import flash.display.Sprite;
import flash.events.Event;
import flash.events.KeyboardEvent;
import flash.events.TextEvent;
import flash.events.TimerEvent;
import flash.filters.DropShadowFilter;
import flash.text.TextField;
import flash.text.TextFieldAutoSize;
import flash.text.TextFieldType;
import flash.text.TextFormat;
import flash.utils.Timer;

class Balloon extends Sprite
{
	private var _clientData:ClientData;
	
	/** balloon */
	private var _balloon:Sprite;
	
	/** message TextField */
	private var _messageField:TextField;
	
	/** message max width */
	private var _maxWidth:Number;
	
	/** timer */
	private var _timer:Timer;
	
	/** balloon alpha */
	private static const BALLOON_ALPHA:Number = 0.9;
	
	/** message size */
	private static const MESSAGE_SIZE:Number = 11;
	
	/** message font */
	private static const MESSAGE_FONT:String = "_等幅";
	
	/** message mergin */
	private static const MESSAGE_MERGIN:uint = 10;
	
	/**
	 * construcor
	 */
	public function Balloon(clientData:ClientData, maxWidth:Number = 125) 
	{	
		_clientData = clientData;
		
		cacheAsBitmap = true;
		// balloon image
		_balloon = new Sprite();
		_balloon.filters = [new DropShadowFilter(4.0, 45, 0, 0.3)];
		addChild(_balloon);
			
		// message text
		var messageFormat:TextFormat = new TextFormat();
		messageFormat.font = MESSAGE_FONT;
		messageFormat.size = MESSAGE_SIZE;
		
		_messageField = new TextField();
		_messageField.type = TextFieldType.DYNAMIC;
		_messageField.autoSize = TextFieldAutoSize.LEFT;
		_messageField.selectable = false;
		_messageField.multiline = true;
		_messageField.width = 0;
		_messageField.defaultTextFormat = messageFormat;
		_messageField.x = _messageField.y = MESSAGE_MERGIN;
		_maxWidth = maxWidth;
		addChild(_messageField);
		
		_timer = new Timer(15000, 1);
	}

	/**
	 * message
	 */
	public function setMessage(msg:String, direction:Number):void
	{
		_timer.stop();
		_timer.removeEventListener(TimerEvent.TIMER, disappear);
		if (msg != _messageField.htmlText)
		{
			if (!msg) msg = "";
			_messageField.visible = false;
			_messageField.width = 0;
			_messageField.wordWrap = false;
			_messageField.htmlText = msg;
			
			if (_messageField.width >= _maxWidth) {
				_messageField.width = _maxWidth;
				_messageField.wordWrap = true;
			} else {
				_messageField.wordWrap = false;
			}
			_messageField.visible = true;
		}
			
		setDirection(direction);
		visible = true;
		_timer.addEventListener(TimerEvent.TIMER, disappear);
		_timer.start();
	}
	
	/**
	 * move balloon
	 * @param	direction(0:up, 1:right, 2:down, 3:left)
	 */
	public function setDirection(direction:uint):void
	{
		var gra:Graphics = _balloon.graphics;
		gra.clear();
		if (_messageField.htmlText == "") return;
		var ballonWidth:Number  = _messageField.width + MESSAGE_MERGIN * 2;
		var ballonHeight:Number = _messageField.height + MESSAGE_MERGIN * 2;
		gra.beginFill(0xFFFFFF, BALLOON_ALPHA);
		gra.drawRoundRect(0, 0,	ballonWidth, ballonHeight, 20, 20);
		gra.endFill();
		
		
		
		switch (direction)
		{
			case 1: // 噴出しの三角が右に表示
			{
				gra.beginFill(0xFFFFFF, BALLOON_ALPHA);
				gra.moveTo(0  + ballonWidth, 10);
				gra.curveTo(2 + ballonWidth,  9, 13 + ballonWidth, 21);
				gra.curveTo(5 + ballonWidth, 16,  0 + ballonWidth, 17);
				gra.endFill();
				_balloon.x = 0;
				_messageField.x = MESSAGE_MERGIN;
				break;
			}
			case 3: // 噴出しの三角が左に表示
			{
				gra.beginFill(0xFFFFFF, BALLOON_ALPHA);
				gra.moveTo(0, 10);
				gra.curveTo(-2,  9,-13, 21);
				gra.curveTo(-5, 16,  0, 17);
				gra.endFill();
				_balloon.x = 13;
				_messageField.x = 13 + MESSAGE_MERGIN;
				break;
			}
		}
	}
	
	/**
	 * disappear
	 * @param	event
	 */
	private function disappear(event:TimerEvent):void
	{
		_timer.removeEventListener(TimerEvent.TIMER, disappear);
		_messageField.htmlText = "";
		_clientData.comment = "";
		visible = false;
	}
}

/**
 * RGB Color palette
 * 
 * @author Copyright (C) naoto koshikawa, All Rights Reserved.
 */
import flash.display.BitmapData;
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;

class ColorPalette extends Sprite
{
	//----------------------------------------------------------------------
	//  properties
	//----------------------------------------------------------------------
	//------------------------------
	//  public properties
	//------------------------------
	private var _bitmapData:BitmapData;
	/** 
	 * 参照用 bitmapData<br />
	 * カラーピッカーとして利用する場合にはColorPaletteにMouseEventのリスナーを登録し<br />
	 * ハンドラ内でBitmapData::getPixelやBitmapData::getPixel32を用いて<br />
	 * パレット内の色を参照して下さい。
	 */
	public function get bitmapData():BitmapData
	{
		return _bitmapData;
	}
	
	//----------------------------------------------------------------------
	//  method
	//----------------------------------------------------------------------
	/**
	 * constructor
	 * @param	colorStep	パレットの色ステップを指定します。0x33でweb safe colorが生成されます。
	 * @param	cellSize	パレットのセルのサイズを指定します。
	 * @param	cellMargin	パレットのセル同士のマージンを指定します。
	 * @param	colmunCount	パレットの1区画分の塊を横方向にいくつ配置するかを指定します。
	 */
	public function ColorPalette(colorStep:uint, cellSize:uint = 10, cellMargin:Number = 0, columnCount:uint = 2) 
	{
		var generator:ColorGenerator = new ColorGenerator(colorStep);
		var colors:Array = generator.colors;
		var count:uint = generator.eachCount;
		var colorList:Array = [];
		var container:Sprite = new Sprite();
		container.graphics.drawRect(
				0, 
				0, 
				count * (cellSize + cellMargin) * columnCount - cellMargin, 
				count * (cellSize + cellMargin) * count / columnCount - cellMargin
		);
		addChild(container);
		
		for (var r:uint = 0; r < count; r++)
		{
			for (var g:uint = 0; g < count; g++)
			{
				for (var b:uint = 0; b < count; b++)
				{
					var cellX:uint = r * (cellSize + cellMargin) * count 
							+ g * (cellSize + cellMargin) 
							- Math.floor(r / columnCount) * (cellSize + cellMargin) * count * columnCount;
					var cellY:uint = Math.floor(r / columnCount) * (cellSize + cellMargin) * count 
							+ b * (cellSize + cellMargin);
					var cell:Shape = new Shape();
					var cellGraphics:Graphics = cell.graphics;
					cellGraphics.beginFill(colors[r][g][b], 1.0);
					cellGraphics.drawRect(0, 0, cellSize, cellSize);
					cell.x = cellX;
					cell.y = cellY;
					colorList.push(container.addChild(cell));
				}
			}
		}
		_bitmapData = new BitmapData(width, height, true, 0);
		_bitmapData.draw(this);
	}
}

/**
 * color generator
 * @author naoto koshikawa
 */
class ColorGenerator 
{
	//----------------------------------------------------------------------
	//  properties
	//----------------------------------------------------------------------
	//------------------------------
	//  static
	//------------------------------
	/**
	 * step of web safe color
	 */
	public static const WEB_SAFE_COLOR:uint = 0x33;
	
	/**
	 * error message
	 */
	private static const ERROR_MESSAGE:String  = "arguments error";
	
	/**
	 * rgb element max
	 */
	private static const RGB_ELEMENT_MAX:uint = 0xFF;
	
	//------------------------------
	//  public properties
	//------------------------------
	private var _colors:Array;
	/**
	 * generated colors Array
	 */
	public function get colors():Array
	{
		return _colors;
	}
	
	private var _eachCount:uint;
	/**
	 * each count of per color element
	 */
	public function get eachCount():uint
	{
		return _eachCount;
	}
	
	private var _count:uint;
	/**
	 * color count
	 */
	public function get count():uint
	{
		return _count;
	}
	
	/**
	 * element step
	 */
	private var _step:uint;
	
	
	
	//----------------------------------------------------------------------
	//  method
	//----------------------------------------------------------------------
	/**
	 * constructor
	 * @param	step	step generated colors
	 */
	public function ColorGenerator(step:uint = ColorGenerator.WEB_SAFE_COLOR) 
	{
		if (step == 0) throw(ArgumentError(ERROR_MESSAGE));
		if (RGB_ELEMENT_MAX < step) throw(ArgumentError(ERROR_MESSAGE));
		if (RGB_ELEMENT_MAX % step != 0) throw(ArgumentError(ERROR_MESSAGE));
		
		_step = step;
		_eachCount = RGB_ELEMENT_MAX / _step + 1;
		_count = _eachCount * _eachCount * _eachCount; // R colors *  G colors * B colors
		generate();
	}
	
	/** 
	 * generate colors
	 */
	private function generate():void
	{
		_colors = [];
		for (var r:uint = 0; r < _eachCount; r++)
		{
			_colors[r] = [];
			for (var g:uint = 0; g < _eachCount; g++)
			{
				_colors[r][g] = [];
				for (var b:uint = 0; b < _eachCount; b++)
				{
					_colors[r][g][b] = _step * r << 16 | _step * g << 8 | _step * b;
				}
			}
		}
	}
}