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

Регистрация: Dec 2009
Сообщений: 125
Код AS3:
package {
	import flash.display.Shape;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
 
	public class Checkbox extends Sprite {
		public var state:Boolean = true;
		private var _mark:Shape;
 
		public function Checkbox() {
			this.graphics.beginFill(0xcccccc, 1);
			this.graphics.drawRect(0, 0, 30, 30);
			this.graphics.endFill();
			this.graphics.beginFill(0xdddddd, 1);
			this.graphics.drawRect(3, 3, 24, 24);
			this.graphics.endFill();
 
			turnOn();
 
			this.buttonMode = true;
			this.mouseChildren  = false;
 
			this.addEventListener(MouseEvent.CLICK, turn);
		}
 
		private function turn(e:MouseEvent):void {
			if (state) {
				turnOff();
			}else {
				turnOn();
			}
		}
 
		public function turnOn():void {
			_mark = new Shape();
			_mark.graphics.lineStyle(5,0x7DE053, 1)
			_mark.graphics.moveTo(5, 5);
			_mark.graphics.lineTo(15, 25);
			_mark.graphics.lineTo(25, 5);
			addChild(_mark);
			state = true;
		}
		public function turnOff():void {
			removeChild(_mark);
			_mark = null;
 
			state = false;
		}
	}
 
}