-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCollectionObject.as
158 lines (122 loc) · 3.69 KB
/
CollectionObject.as
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
package {
import id.core.TouchComponent;
import flash.display.Shape;
import flash.display.Stage;
import id.element.Graphic;
import ScrollerThumb;
public class CollectionObject extends TouchComponent{
private var backdrop:Shape;
private var infoBar:Graphic;
private var titleDisplay:TextDisplay;
private var nameDisplay:TextDisplay;
private var display:Array;
private var titleInfo:String;
private var nameInfo:String;
private var input:Array;
private var _id:int;
public function CollectionObject(t:String, n:String, i:Array, iD:int) {
titleInfo = t;
nameInfo = n;
input = i;
_id = iD;
createUI();
commitUI();
}
public function get title():String{
return titleInfo;
}
override public function get name():String{
return nameInfo;
}
public function get images():Array{
return input;
}
override public function get id():int{
return _id;
}
override public function Dispose():void{
infoBar.removeChild(titleDisplay);
titleDisplay.Dispose();
titleDisplay = null;
infoBar.removeChild(nameDisplay);
nameDisplay.Dispose();
nameDisplay = null;
removeChild(infoBar);
infoBar.graphics.clear();
infoBar = null;
removeChild(backdrop);
backdrop.graphics.clear();
backdrop = null;
for each(var i:ScrollerThumb in display){
i.Dispose();
i = null;
}
display = null;
}
override protected function createUI():void{
backdrop = new Shape();
infoBar = new Graphic();
titleDisplay = new TextDisplay();
nameDisplay = new TextDisplay();
display = new Array();
addChild(backdrop);
infoBar.addChild(titleDisplay);
infoBar.addChild(nameDisplay);
addChild(infoBar);
for(var i:int = 0; i < input.length; ++i){
var thumb:ScrollerThumb = new ScrollerThumb();
thumb.blobContainerEnabled = false;
thumb.scaleX = .83;
thumb.scaleY = .83;
display.push(thumb);
addChild(thumb);
}
}
override protected function commitUI():void{
for(var i:int = 0; i < display.length; ++i){
display[i].id = input[i];
}
titleDisplay.styleList = {fontColor:0xFFFFFF,fontSize:16};
titleDisplay.text = titleInfo;
titleDisplay.multilined = false;
nameDisplay.styleList = {fontColor:0xFFFFFF,fontSize:12};
nameDisplay.text = nameInfo;
nameDisplay.multilined = false;
infoBar.alpha = .8;
infoBar.fillColor1 = 0x232323;
}
override protected function layoutUI():void{
try{
var padding:int = 5;
backdrop.alpha = .8;
backdrop.graphics.beginFill(0x232323);
backdrop.graphics.drawRect(0,0, stage.stageWidth, 100 + padding * 2);
backdrop.graphics.endFill();
var biggest:Number = 0;
if(titleDisplay.width > biggest){
biggest = titleDisplay.width;
infoBar.width = padding * 2 + biggest;
}
if(nameDisplay.width > biggest){
infoBar.width = padding * 2 + nameDisplay.width;
}
infoBar.height = titleDisplay.height + nameDisplay.height + padding * 2;
infoBar.x = stage.stageWidth/2 - infoBar.width/2;
titleDisplay.x = infoBar.width/2 - titleDisplay.width/2 - 2;
titleDisplay.y = padding;
nameDisplay.x = infoBar.width/2 - nameDisplay.width/2 - 2;
nameDisplay.y = titleDisplay.y + titleDisplay.height;
backdrop.y = infoBar.height;
var startPos = stage.stageWidth/2 - (((display.length * 100) + (padding * (display.length -1)))/2);
display[0].y = backdrop.y + padding;
display[0].x = startPos;
for(var i:int = 1; i < display.length; ++i){
display[i].y = display[i-1].y;
display[i].x = display[i-1].x + display[i-1].width*.83 + padding;
}
}
catch(e:Error){
}
}
}
}