Fix hair, dick around with new game screen.
[18plus-7leafadventure.git] / src / org / sevenchan / dongs / ui / SexPanel.as
blobc96fb7d3e0747b90739dffd5e3f3a6283f8cacfc
1 package org.sevenchan.dongs.ui
3 import flash.display.DisplayObject;
4 import flash.display.MovieClip;
5 import flash.display.Sprite;
6 import flash.events.Event;
7 import mx.controls.VScrollBar;
8 import flash.events.MouseEvent;
9 import flash.geom.*;
10 import flash.text.StyleSheet;
11 import flash.text.TextField;
12 import flash.text.TextFormat;
13 import mx.core.Application;
14 //import classes.Scroller.Scroller;
16 /**
17 * ...
18 * @author Harbinger
20 public class SexPanel extends MovieClip
22 public var bgColorTop:uint = 0x999999;
23 public var bgColorMain:uint = 0xcccccc;
24 public var fgColor:uint = 0x000000;
25 private var textControl:TextField = new TextField();
26 private const padding:Number = 4;
27 public const alphaNormal:Number = 0.90;
28 public const alphaHover:Number = 0.75;
29 private var stackedControls:Array = new Array();
30 private var scrollUp:TinyButton = new TinyButton("˄");
31 private var scrollDown:TinyButton = new TinyButton("˅");
32 private var bounds:Rectangle;
33 private var bgpanel:Sprite = new Sprite();
35 public function SexPanel(text:String)
37 this.textControl.htmlText = text;
38 this.textControl.textColor = fgColor;
40 //this.alpha = alphaNormal;
42 addChild(bgpanel);
43 addChild(textControl);
45 var style:StyleSheet = new StyleSheet();
46 style.parseCSS("" +
47 "h2 { font-size:24;font-weight:bold;padding-bottom:32px;font-family:'Georgia','Times New Roman',_serif;}"+
48 "p,li { font-family:'Georgia','Times New Roman',_serif;font-size:14;margin-bottom:1em; }" +
49 "a {color:#0000ff;text-decoration:underline;}");
50 textControl.styleSheet = style;
51 this.textControl.multiline = true;
52 this.textControl.wordWrap = true;
53 textControl.alpha = 0.9;
54 this.alpha = 0.9;
56 addChild(scrollUp);
57 addChild(scrollDown);
59 scrollUp.addEventListener(MouseEvent.CLICK, this.upScroll);
60 scrollDown.addEventListener(MouseEvent.CLICK, this.downScroll);
61 textControl.addEventListener(MouseEvent.MOUSE_WHEEL, this.wheelScroll);
64 public function get text():String {
65 return textControl.htmlText;
67 public function set text(value:String):void {
68 textControl.text = "";
69 textControl.htmlText = value
70 .replace(/<\/p>/g, "</p><br />")
71 .replace(/<\/h2>/g,"</h2><br />")
72 .replace(/<\/ul>/g,"</ul><br />")
73 .replace(/(\r?)\n/g,"")
74 .replace(/\t/g,"");
75 textControl.alpha = 1;
76 updateScrollers();
79 public function updateScrollers():void {
80 scrollUp.visible = (textControl.scrollV > 1);
81 scrollDown.visible = (textControl.scrollV < textControl.maxScrollV);
84 public function stackMode():void {
85 removeChild(textControl);
88 public function addToStack(_do:DisplayObject):void {
89 addChild(_do);
90 stackedControls.push(_do);
91 //arrangeStack();
94 public function delFromStack(_do:DisplayObject):void {
95 removeChild(_do);
96 delete stackedControls[stackedControls.indexOf(_do)];
97 //arrangeStack();
100 public function arrangeStack():void {
101 var bottom:Number = 0;
102 for (var i:int = 0; i < stackedControls.length; i++) {
103 var o:DisplayObject = stackedControls[i];
104 o.x = (this.width/2)-(o.width/2);
105 o.y = bottom;
106 bottom += o.height + padding;
107 //o.width = width;
111 public function draw(h:Number, w:Number):void {
112 graphics.clear();
113 doGradFilled(0, 0, h, w);
114 textControl.height = h - (padding * 2);
116 textControl.width = w-(padding * 2);
117 textControl.x = (w / 2) - (textControl.width / 2);
118 textControl.y = (h / 2) - (textControl.height / 2)
121 scrollUp.x = scrollDown.x = width - scrollUp.width;
123 scrollUp.y = 3;
124 scrollDown.y = height - scrollDown.width;
125 updateScrollers();
128 private function upScroll(event:MouseEvent):void
130 trace(textControl.scrollV);
131 textControl.scrollV -= 1;
132 updateScrollers();
135 private function wheelScroll(e:MouseEvent):void {
136 updateScrollers();
139 private function downScroll(event:MouseEvent):void
141 trace(textControl.scrollV);
142 textControl.scrollV += 1;
143 updateScrollers();
146 public function doGradFilled(x:Number, y:Number, h:Number, w:Number):void {
148 bgpanel.graphics.clear();
149 var fillType:String = "linear";
150 var colors:Array = [bgColorTop, bgColorMain];
151 var alphas:Array = [1, 1];
152 var ratios:Array = [0, 128];
153 var matrix:Matrix = new Matrix();
154 var gradWidth:Number = w;
155 var gradHeight:Number = h;
156 var gradRotation:Number = 90 / 180 * Math.PI; // rotation expressed in radians
157 var gradOffsetX:Number = 0;
158 var gradOffsetY:Number = 0;
160 matrix.createGradientBox(gradWidth, gradHeight, gradRotation, gradOffsetX, gradOffsetY);
161 var spreadMethod:String = "pad";
162 bgpanel.graphics.lineStyle(1, 0x000000, 1);
163 bgpanel.graphics.beginGradientFill(fillType, colors, alphas, ratios, matrix, spreadMethod);
164 bgpanel.graphics.drawRoundRect(0, 0, w,h,5,5);
165 bgpanel.graphics.endFill();
166 bgpanel.graphics.lineStyle();
168 bgpanel.x = x;
169 bgpanel.y = y;