-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenImage.as
247 lines (199 loc) · 6.23 KB
/
ScreenImage.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
package
{
import flash.display.MovieClip;
import com.seajean.base.RoundImage;
import flash.events.Event;
import com.seajean.base.Loading;
import com.seajean.visual.BlurExBackGround;
import com.greensock.TweenLite;
import flash.events.MouseEvent;
import flash.display.Sprite;
import com.seajean.base.RoundRec;
import flash.geom.Rectangle;
import com.greensock.easing.Strong;
public class ScreenImage extends MovieClip
{
//private var bg:BlurExBackGround;
//private var loading:Loading;
private var prevBtn:NavBtn;
private var nextBtn:NavBtn;
private var bigImage:PhotoSlider;
private var cover:Sprite
private var closeBtn:CloseBtn;
private var ctrlPanel:MovieClip;
private var aniBg:RoundRec;
private var _vo:PhotoVo;
private var _datas:Vector.<PhotoVo>;
private var photoDesc:PhotoDesc;
private var showed:Boolean;
public function ScreenImage()
{
aniBg=new RoundRec(64,48,15,0x000000,1);
aniBg.visible=false;
aniBg.alpha=0;
var rec:Rectangle=new Rectangle(15,15,34,18);
aniBg.scale9Grid=rec;
addChild(aniBg);
showed=false;
this.addEventListener(Event.ADDED_TO_STAGE,init);
}
private function init(e:Event):void{
this.removeEventListener(Event.ADDED_TO_STAGE,init);
//bg=new BlurExBackGround(stage,stage.stageWidth,stage.stageHeight);
//addChild(bg);
bigImage=new PhotoSlider();
addChild(bigImage);
cover=new Sprite();
cover.graphics.beginBitmapFill(new CoverData(),null,true);
cover.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
cover.graphics.endFill();
cover.alpha=0.5;
addChild(cover);
cover.visible=false;
bigImage.addEventListener(Event.COMPLETE,onImageLoaded);
//==================================
//CTRL面板
//===================================
ctrlPanel=new MovieClip();
prevBtn=new NavBtn();
nextBtn=new NavBtn();
prevBtn.rotation=180;
ctrlPanel.addChild(prevBtn);
ctrlPanel.addChild(nextBtn);
closeBtn=new CloseBtn();
ctrlPanel.addChild(closeBtn);
prevBtn.y=stage.stageHeight/2+40;
prevBtn.x=100;
nextBtn.x=stage.stageWidth-100;
nextBtn.y=stage.stageHeight/2-20;
closeBtn.x=stage.stageWidth-30;
closeBtn.y=-20;
prevBtn.buttonMode=true;
nextBtn.buttonMode=true;
closeBtn.buttonMode=true;
addChild(ctrlPanel);
ctrlPanel.visible=false;
//====================================
//trace("ook")
nextBtn.addEventListener(MouseEvent.CLICK,onNext);
prevBtn.addEventListener(MouseEvent.CLICK,onPrev);
closeBtn.addEventListener(MouseEvent.CLICK,onClose);
stage.addEventListener(Event.RESIZE,onResize);
photoDesc=new PhotoDesc();
photoDesc.y=stage.stageHeight;
photoDesc.x=0;
photoDesc.bg.width=stage.stageWidth;
addChild(photoDesc);
}
private function onResize(e:Event):void{
cover.graphics.clear();
cover.graphics.beginBitmapFill(new CoverData(),null,true);
cover.graphics.drawRect(0,0,stage.stageWidth,stage.stageHeight);
cover.graphics.endFill();
prevBtn.y=stage.stageHeight/2+40;
prevBtn.x=100;
nextBtn.x=stage.stageWidth-100;
nextBtn.y=stage.stageHeight/2-20;
closeBtn.x=stage.stageWidth-30;
closeBtn.y=-20;
photoDesc.y=stage.stageHeight+5;
photoDesc.x=0;
photoDesc.bg.width=stage.stageWidth;
//photoDesc.y=0;
//photoDesc.x=stage.stageWidth;
//photoDesc.visible=false;
//addChild(photoDesc);
if(this.showed){
this.showDesc();
}
}
private function onClose(e:MouseEvent):void{
this.clear();
}
private function hideDesc(cb:Function=null):void{
//var callBack=cb;
TweenLite.to(photoDesc,0.5,{"y":stage.stageHeight+30,"onComplete":function(){
}});
}
private function showDesc(){
//photoDesc.alpha=0;
if(!_vo.desc) return;
photoDesc.x=0;
//photoDesc.y=stage.stageHeight-200-Math.random()*100;
photoDesc.data=_vo;
TweenLite.to(photoDesc,0.5,{"y":stage.stageHeight-photoDesc.height+5});
}
private function onPrev(e:MouseEvent):void{
if(bigImage.loading||bigImage.tweening) return;
TweenLite.to(photoDesc,0.3,{"y":stage.stageHeight+30,"ease":Strong.easeIn,"onComplete":function(){
var index=_vo.index-1;
if(index<0) index=_datas.length-1;
_vo=_datas[index];
bigImage.prev(_datas[index].src);
prevBtn.showLoading();
}});
}
private function onNext(e:MouseEvent):void{
if(bigImage.loading||bigImage.tweening) return;
if(bigImage.loading||bigImage.tweening) return;
TweenLite.to(photoDesc,0.3,{"y":stage.stageHeight+30,"ease":Strong.easeIn,"onComplete":function(){
var index=_vo.index+1;
if(index==_datas.length) index=0;
_vo=_datas[index];
bigImage.next(_datas[index].src);
nextBtn.showLoading();
}});
}
private function onImageClick(e:MouseEvent):void{
bigImage.clear();
//bg.clear();
}
private function onImageLoaded(e:Event){
cover.visible=true;
ctrlPanel.visible=true;
nextBtn.showArrow();
prevBtn.showArrow();
showDesc();
}
private function hideBack():void{
ctrlPanel.visible=false;
var thumb:PhotoThumb=_vo.target;
showed=false;
TweenLite.to(aniBg,0.3,{"width":thumb.width,"height":thumb.height,"x":thumb.x,"y":thumb.y,alpha:0.1,onComplete:function(){
aniBg.visible=false;
_vo=null;
//state=PhotoBox.STATE_INIT;
}});
}
public function set photos(vos:Vector.<PhotoVo>):void{
_datas=vos;
}
public function get data():PhotoVo{
return this._vo;
}
public function set data(vo:PhotoVo):void{
aniBg.visible=true;
var thumb=vo.src;
aniBg.x=vo.target.x;
aniBg.y=vo.target.y;
aniBg.width=vo.target.width;
aniBg.height=vo.target.height;
_vo=vo;
TweenLite.to(aniBg,0.1,{alpha:0.2,"onComplete":function(){
showed=true;
TweenLite.to(aniBg,0.2,{"width":stage.stageWidth+20,"height":stage.stageHeight+20,"x":-10,"y":-10,onComplete:function(){
bigImage.load(thumb);
//TweenLite.to(bg,0.5,{alpha:1,ease:Bounce.easeOut});
}});
}});
this.dispatchEvent(new Event(PhotoEvent.SHOW_LOADING));
}
private function clear():void{
bigImage.clear();
//bg.clear();
cover.visible=false;
hideBack();
this.photoDesc.y=stage.stageHeight+30;
}
}
}