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;
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;
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();
34 public function SexPanel
(text
:String)
36 this.textControl
.htmlText
= text
;
37 this.textControl
.textColor
= fgColor
;
39 //this.alpha = alphaNormal;
42 addChild
(textControl
);
44 var style
:StyleSheet = new StyleSheet();
46 "h2 { font-size:24;font-weight:bold;padding-bottom:32px;font-family:'Georgia','Times New Roman',_serif;}"+
47 "p,li { font-family:'Georgia','Times New Roman',_serif;font-size:14;margin-bottom:1em; }");
48 textControl
.styleSheet
= style
;
49 this.textControl
.multiline
= true;
50 this.textControl
.wordWrap
= true;
51 textControl
.alpha
= 0.9;
57 scrollUp
.addEventListener
(MouseEvent.CLICK
, this.upScroll
);
58 scrollDown
.addEventListener
(MouseEvent.CLICK
, this.downScroll
);
59 textControl
.addEventListener
(MouseEvent.MOUSE_WHEEL
, this.wheelScroll
);
62 public function get text
():String {
63 return textControl
.htmlText
;
65 public function set text
(value
:String):void {
66 textControl
.text
= "";
67 textControl
.htmlText
= value
68 .replace
(/<\/p
>/g
, "</p><br />")
69 .replace
(/<\/h2
>/g
,"</h2><br />")
70 .replace
(/<\/ul
>/g
,"</ul><br />")
71 .replace
(/(\r?)\n/g
,"")
73 textControl
.alpha
= 1;
77 public function updateScrollers
():void {
78 scrollUp
.visible
= (textControl
.scrollV
> 1);
79 scrollDown
.visible
= (textControl
.scrollV
< textControl
.maxScrollV
);
82 public function stackMode
():void {
83 removeChild
(textControl
);
86 public function addToStack
(_do
:DisplayObject):void {
88 stackedControls
.push
(_do
);
92 public function delFromStack
(_do
:DisplayObject):void {
94 delete stackedControls
[stackedControls
.indexOf
(_do
)];
98 public function arrangeStack
():void {
99 var bottom
:Number = 0;
100 for (var i
:int = 0; i
< stackedControls
.length
; i
++) {
101 var o
:DisplayObject = stackedControls
[i
];
102 o
.x
= (this.width
/2)-(o
.width
/2);
104 bottom
+= o
.height
+ padding
;
109 public function draw
(h
:Number,w
:Number):void {
110 doGradFilled
(0, 0, h
, w
);
111 textControl
.height
= h
- (padding
* 2);
113 textControl
.width
= w
-(padding
* 2);
114 textControl
.x
= (w
/ 2) - (textControl
.width
/ 2);
115 textControl
.y
= (h
/ 2) - (textControl
.height
/ 2)
118 scrollUp
.x
= scrollDown
.x
= width
- scrollUp
.width
;
121 scrollDown
.y
= height
- scrollDown
.width
;
125 private function upScroll
(event
:MouseEvent):void
127 trace
(textControl
.scrollV
);
128 textControl
.scrollV
-= 1;
132 private function wheelScroll
(e
:MouseEvent):void {
136 private function downScroll
(event
:MouseEvent):void
138 trace
(textControl
.scrollV
);
139 textControl
.scrollV
+= 1;
143 public function doGradFilled
(x
:Number, y
:Number, h
:Number, w
:Number):void {
145 bgpanel
.graphics
.clear
();
146 var fillType
:String = "linear";
147 var colors
:Array = [bgColorTop
, bgColorMain
];
148 var alphas
:Array = [1, 1];
149 var ratios
:Array = [0, 128];
150 var matrix
:Matrix = new Matrix();
151 var gradWidth
:Number = w
;
152 var gradHeight
:Number = h
;
153 var gradRotation
:Number = 90 / 180 * Math.PI
; // rotation expressed in radians
154 var gradOffsetX
:Number = 0;
155 var gradOffsetY
:Number = 0;
157 matrix
.createGradientBox
(gradWidth
, gradHeight
, gradRotation
, gradOffsetX
, gradOffsetY
);
158 var spreadMethod
:String = "pad";
159 bgpanel
.graphics
.lineStyle
(1, 0x000000, 1);
160 bgpanel
.graphics
.beginGradientFill
(fillType
, colors
, alphas
, ratios
, matrix
, spreadMethod
);
161 bgpanel
.graphics
.drawRoundRect
(0, 0, w
,h
,5,5);
162 bgpanel
.graphics
.endFill
();
163 bgpanel
.graphics
.lineStyle
();