michaelforrest-tidy 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +87 -0
- data/README +5 -0
- data/Rakefile +14 -0
- data/bin/tidyproject +33 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/animator/Animator.as +86 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/animator/Transition.as +142 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/group/Parallel.as +28 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/group/Queue.as +93 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/group/Sequence.as +28 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/group/Set.as +82 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/group/Stack.as +30 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/single/Animation.as +173 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/single/Message.as +36 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/single/MethodWithCompleteEvent.as +75 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/single/OrphanEvent.as +78 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/single/Pause.as +35 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/single/Tween.as +73 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/util/Easing.as +158 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/util/Engine.as +35 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/util/GroupCommon.as +62 -0
- data/lib/aslibs/as3/lbi/com/lbi/animation/util/IAnimation.as +30 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/DraggyClip.as +96 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/FPSView.as +48 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/KeySequenceTrigger.as +60 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/Log.as +168 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/LogItemType.as +23 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/LogType.as +31 -0
- data/lib/aslibs/as3/lbi/com/lbi/debug/ViewAnalysis.as +24 -0
- data/lib/aslibs/as3/lbi/com/lbi/media/IBufferable.as +16 -0
- data/lib/aslibs/as3/lbi/com/lbi/media/ITransportControllable.as +11 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Collection.as +296 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/ISearchable.as +10 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/ISelectable.as +10 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Matchable.as +9 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Searchable.as +56 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/collection/Selectable.as +49 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/Cloner.as +15 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/TypographyBase.as +194 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/helper/preloading/LoadProgressEvent.as +18 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Application.as +45 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/ConcurrentDependencyLoader.as +27 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/EventMapper.as +85 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Hyperlink.as +36 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/IEventMapper.as +10 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/Merge.as +14 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/SequentialDependencyLoader.as +43 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/StringFormatting.as +142 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/XMLListLoader.as +98 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/model/XMLListLoaderDispatcher.as +52 -0
- data/lib/aslibs/as3/lbi/com/lbi/mvc/view/ViewBase.as +323 -0
- data/lib/aslibs/as3/lbi/com/quasimondo/geom/ColorMatrix.as +682 -0
- data/lib/script/as2/lib/as2_class.rb +37 -0
- data/lib/script/as2/lib/test/SampleClass.as +34 -0
- data/lib/script/as2/lib/test/as2_class_test.rb +15 -0
- data/lib/script/as2/navigation/bin/xml/__model.xml +7 -0
- data/lib/script/as2/navigation/navigation.rb +44 -0
- data/lib/script/as2/navigation/src/app/models/App.as +14 -0
- data/lib/script/as2/navigation/src/app/models/__Model.as +42 -0
- data/lib/script/as2/navigation/src/app/views/__model/__ModelView.as +61 -0
- data/lib/script/as2/navigation/src/app/views/__model/__ModelsView.as +33 -0
- data/lib/script/as2/project/project.rb +7 -0
- data/lib/script/as2/project/src/app/helpers/Colours.as +1 -0
- data/lib/script/as2/project/src/app/helpers/Typography.as +1 -0
- data/lib/script/as2/project/src/app/models/App.as +22 -0
- data/lib/script/as2/project/src/app/models/FlashVars.as +1 -0
- data/lib/script/as2/project/src/app/models/Linkages.as +8 -0
- data/lib/script/as2/project/src/app/views/AppView.as +21 -0
- data/lib/script/as3/project/project.rb +10 -0
- data/lib/script/as3/project/src/app/helpers/Colours.as +1 -0
- data/lib/script/as3/project/src/app/helpers/Typography.as +1 -0
- data/lib/script/as3/project/src/app/models/App.as +21 -0
- data/lib/script/as3/project/src/app/models/FlashVars.as +1 -0
- data/lib/script/as3/project/src/app/views/AppView.as +27 -0
- data/lib/script/as3/scaffold/bin/xml/__model.xml +0 -0
- data/lib/script/as3/scaffold/scaffold.rb +41 -0
- data/lib/script/as3/scaffold/src/models/__Model.as +11 -0
- data/lib/script/as3/scaffold/src/views/__model/__ModelDetailView.as +0 -0
- data/lib/script/as3/scaffold/src/views/__model/__ModelListItemView.as +0 -0
- data/lib/script/as3/scaffold/src/views/__model/__ModelListView.as +0 -0
- data/lib/script/bwlimit.rb +305 -0
- data/lib/script/generate +117 -0
- data/lib/script/server +4 -0
- data/lib/script/server.rb +20 -0
- data/lib/tidy_project.rb +19 -0
- data/tasks/build.rake +4 -0
- data/tasks/release.rake +8 -0
- data/test/test_tidy_project.rb +22 -0
- data/tidy.gemspec +33 -0
- metadata +229 -0
@@ -0,0 +1,323 @@
|
|
1
|
+
package com.lbi.mvc.view {
|
2
|
+
import app.helpers.Typography;
|
3
|
+
|
4
|
+
import com.lbi.animation.animator.Animator;
|
5
|
+
import com.lbi.mvc.helper.TypographyBase;
|
6
|
+
|
7
|
+
import flash.display.Bitmap;
|
8
|
+
import flash.display.BitmapData;
|
9
|
+
import flash.display.DisplayObject;
|
10
|
+
import flash.display.Loader;
|
11
|
+
import flash.display.LoaderInfo;
|
12
|
+
import flash.display.Sprite;
|
13
|
+
import flash.events.Event;
|
14
|
+
import flash.events.IOErrorEvent;
|
15
|
+
import flash.events.MouseEvent;
|
16
|
+
import flash.filters.BlurFilter;
|
17
|
+
import flash.geom.Matrix;
|
18
|
+
import flash.geom.Point;
|
19
|
+
import flash.geom.Rectangle;
|
20
|
+
import flash.net.URLRequest;
|
21
|
+
import flash.text.TextField;
|
22
|
+
import flash.utils.getTimer;
|
23
|
+
|
24
|
+
/**
|
25
|
+
* @author michaelforrest
|
26
|
+
*/
|
27
|
+
public class ViewBase extends Sprite {
|
28
|
+
public static const HORIZONTAL : String = "horizontal";
|
29
|
+
public static const VERTICAL : String = "vertical";
|
30
|
+
private var nextX : Number = 0;
|
31
|
+
public var nextY : Number = 0;
|
32
|
+
public var spacing : Number = 0;
|
33
|
+
public var leftMargin : Number = 0;
|
34
|
+
public var columnWidth : Number = 225;
|
35
|
+
private var elements : Array;
|
36
|
+
public var topMargin : Number = 0;
|
37
|
+
|
38
|
+
|
39
|
+
public var animator : Animator;
|
40
|
+
private var unique_id : String;
|
41
|
+
protected var image : ViewBase;
|
42
|
+
private var image_url : String;
|
43
|
+
private var loader : Loader;
|
44
|
+
|
45
|
+
private var __visibility: Number;
|
46
|
+
private var clickedPoint : Point;
|
47
|
+
|
48
|
+
private var __anchor: Point = new Point(0, 0);
|
49
|
+
private static var nextTextFieldID : Number = 0;
|
50
|
+
|
51
|
+
public function get anchor():Point{
|
52
|
+
return __anchor;
|
53
|
+
}
|
54
|
+
public function set anchor(v : Point):void{
|
55
|
+
__anchor = v;
|
56
|
+
}
|
57
|
+
|
58
|
+
public function get visibility():Number{
|
59
|
+
return __visibility;
|
60
|
+
}
|
61
|
+
public function set visibility(v:Number):void{
|
62
|
+
__visibility = v;
|
63
|
+
}
|
64
|
+
|
65
|
+
public function ViewBase(options : Object = null) {
|
66
|
+
unique_id = "viewbase-" + getTimer() + "-" + Math.random();
|
67
|
+
animator = new Animator(this);
|
68
|
+
visibility = 1;
|
69
|
+
elements = [];
|
70
|
+
if(options) {
|
71
|
+
for (var key : String in options) {
|
72
|
+
this[key] = options[key];
|
73
|
+
}
|
74
|
+
}
|
75
|
+
nextX = leftMargin;
|
76
|
+
nextY = topMargin;
|
77
|
+
}
|
78
|
+
|
79
|
+
public function getPosition() : Point {
|
80
|
+
return new Point(x,y);
|
81
|
+
}
|
82
|
+
|
83
|
+
public function addTextField(style : TypographyBase, rectangle : Rectangle, copy: String ="") : TextField {
|
84
|
+
var txt : TextField = TypographyBase.createTextField(style, rectangle);
|
85
|
+
txt.text = copy;
|
86
|
+
addChild(txt);
|
87
|
+
return txt;
|
88
|
+
}
|
89
|
+
|
90
|
+
public function getUniqueID() : String {
|
91
|
+
return unique_id;
|
92
|
+
}
|
93
|
+
public function setPosition(...args) : void {
|
94
|
+
if(args[0] is Point) {
|
95
|
+
var position : Point = args[0] as Point;
|
96
|
+
x = position.x;
|
97
|
+
y = position.y;
|
98
|
+
}else{
|
99
|
+
x = args[0];
|
100
|
+
y = args[1];
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
public function loadImage(url : String) : ViewBase {
|
105
|
+
if(image){
|
106
|
+
destroyImage();
|
107
|
+
}
|
108
|
+
createImage();
|
109
|
+
image_url = url;
|
110
|
+
loader.load(new URLRequest(url));
|
111
|
+
return image;
|
112
|
+
}
|
113
|
+
|
114
|
+
private function createImage() : void {
|
115
|
+
image = new ViewBase();
|
116
|
+
addChild(image);
|
117
|
+
loader = new Loader();
|
118
|
+
image.addChild(loader);
|
119
|
+
loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded,false,0,true);
|
120
|
+
loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, onIOError,false,0,true);
|
121
|
+
}
|
122
|
+
|
123
|
+
protected function onIOError(event : IOErrorEvent) : void {
|
124
|
+
trace("Error loading "+ image_url);
|
125
|
+
}
|
126
|
+
/**
|
127
|
+
* TODO: think about a less nesty way to convert embedded classes into ViewBases.
|
128
|
+
*/
|
129
|
+
public function add(viewClass : Class, model:Object=null) : ViewBase {
|
130
|
+
var result : DisplayObject = model ? new viewClass(model) : new viewClass();
|
131
|
+
if(!(result is ViewBase)) {
|
132
|
+
return addChildFromLibrary(viewClass);
|
133
|
+
}
|
134
|
+
addChild(result);
|
135
|
+
return result as ViewBase;
|
136
|
+
}
|
137
|
+
protected function destroyImage() : void {
|
138
|
+
try{
|
139
|
+
var li:LoaderInfo = loader.contentLoaderInfo;
|
140
|
+
li.removeEventListener(Event.COMPLETE, onImageLoaded);
|
141
|
+
li.removeEventListener(IOErrorEvent.IO_ERROR, onIOError);
|
142
|
+
if(li.childAllowsParent && li.content is Bitmap){
|
143
|
+
(li.content as Bitmap).bitmapData.dispose(); // remove bitmap from memory
|
144
|
+
}
|
145
|
+
}catch(e:Error){
|
146
|
+
trace('error disposing of image ' + image);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
public function addChildFromLibrary(assetClass : Class, options : Object = null) : ViewBase {
|
150
|
+
var result : ViewBase = new ViewBase();
|
151
|
+
addChild(result);
|
152
|
+
var asset : DisplayObject = new assetClass() as DisplayObject;
|
153
|
+
result.addChild(asset);
|
154
|
+
if(asset.width != result.width) trace("WEIRD. The nested",assetClass,"isn't reporting the right width");
|
155
|
+
if(options && options.center){ // yes I am grudgingly using the american spelling.
|
156
|
+
asset.x = -asset.width/2;
|
157
|
+
asset.y = -asset.height/2;
|
158
|
+
}
|
159
|
+
return result;
|
160
|
+
}
|
161
|
+
|
162
|
+
protected function onImageLoaded(e:Event) : void {
|
163
|
+
|
164
|
+
//Bitmap(loader.content).smoothing = true;
|
165
|
+
}
|
166
|
+
|
167
|
+
protected function enableAsButton() : void {
|
168
|
+
mouseChildren = false;
|
169
|
+
buttonMode = true;
|
170
|
+
useHandCursor = true;
|
171
|
+
}
|
172
|
+
public function append(element : DisplayObject) : DisplayObject {
|
173
|
+
if(!element.parent) addChild(element);
|
174
|
+
placeElement(element);
|
175
|
+
elements.push(element);
|
176
|
+
return element;
|
177
|
+
}
|
178
|
+
|
179
|
+
private var orientation : String = VERTICAL;
|
180
|
+
public function setFlow(orientation : String) : void {
|
181
|
+
this.orientation = orientation;
|
182
|
+
}
|
183
|
+
|
184
|
+
protected function placeElement(element : DisplayObject) : void {
|
185
|
+
if(orientation == VERTICAL){
|
186
|
+
element.x = nextX;
|
187
|
+
element.y = nextY;
|
188
|
+
nextY += element.height + spacing;
|
189
|
+
// trace("object", this,unique_id, "y=", element.y,"element.height=",element.height,"nextY",nextY);
|
190
|
+
}else{
|
191
|
+
element.x = nextX;
|
192
|
+
element.y = nextY;
|
193
|
+
nextX = element.x + element.width + spacing;
|
194
|
+
}
|
195
|
+
}
|
196
|
+
|
197
|
+
public function text(text : String, style : String) : DisplayObject {
|
198
|
+
var txt : TextField = addTextField(Typography.style(style), new Rectangle(leftMargin, 0, columnWidth, 1000));
|
199
|
+
txt.text = text;
|
200
|
+
txt.height = txt.textHeight + 4; // if 2px padding is still the strange magic number
|
201
|
+
return txt;
|
202
|
+
}
|
203
|
+
|
204
|
+
|
205
|
+
public function row(views : Array) : void {
|
206
|
+
var nextX : Number = leftMargin;
|
207
|
+
var maxHeight : Number = 0;
|
208
|
+
for (var i : Number = 0; i < views.length; i++) {
|
209
|
+
var view:DisplayObject = views[i];
|
210
|
+
if(!view.parent) addChild(view);
|
211
|
+
view.y = nextY;
|
212
|
+
view.x = nextX;
|
213
|
+
nextX += view.width + spacing;
|
214
|
+
if(view.height > maxHeight) maxHeight = view.height;
|
215
|
+
elements.push(view);
|
216
|
+
}
|
217
|
+
nextY += maxHeight + spacing;
|
218
|
+
}
|
219
|
+
public function layoutElements() : void {
|
220
|
+
nextX = leftMargin;
|
221
|
+
nextY = topMargin;
|
222
|
+
for (var i : Number = 0; i < elements.length; i++) {
|
223
|
+
var element:DisplayObject = elements[i];
|
224
|
+
placeElement(element);
|
225
|
+
|
226
|
+
}
|
227
|
+
}
|
228
|
+
public function clear() : void {
|
229
|
+
for (var i : Number = 0;i < elements.length; i++) {
|
230
|
+
var element:DisplayObject = elements[i];
|
231
|
+
removeChild(element);
|
232
|
+
element = null;
|
233
|
+
}
|
234
|
+
elements = [];
|
235
|
+
nextY = topMargin;
|
236
|
+
nextX = leftMargin;
|
237
|
+
}
|
238
|
+
|
239
|
+
// private var __scale:Number = 1;
|
240
|
+
// public function get scale():Number{
|
241
|
+
// return __scale;
|
242
|
+
// }
|
243
|
+
// public function set scale(v:Number):void{
|
244
|
+
// __scale = v;
|
245
|
+
// scaleX = scaleY = v;
|
246
|
+
// if(!stage) return;
|
247
|
+
// x = stage.stageWidth / 2 - stage.stageWidth * v / 2;
|
248
|
+
// y = stage.stageHeight / 2 - stage.stageHeight * v / 2;
|
249
|
+
// }
|
250
|
+
|
251
|
+
public function getBlurBehind(rect : Rectangle) : BitmapData{
|
252
|
+
var result : BitmapData = new BitmapData(rect.width,rect.height,true,0x00000000);
|
253
|
+
visible = false;
|
254
|
+
var topLeft : Point = localToGlobal(rect.topLeft);
|
255
|
+
var matrix : Matrix = new Matrix();
|
256
|
+
matrix.translate(-topLeft.x, -topLeft.y);
|
257
|
+
result.draw(stage,matrix,null,null,null);
|
258
|
+
result.applyFilter(result, result.rect, new Point(0,0), new BlurFilter(10,10,2) );
|
259
|
+
visible = true;
|
260
|
+
return result;
|
261
|
+
}
|
262
|
+
|
263
|
+
override public function startDrag(lockCenter : Boolean = false, bounds : Rectangle = null) : void {
|
264
|
+
clickedPoint = new Point(mouseX,mouseY).subtract(anchor);
|
265
|
+
stage.addEventListener(MouseEvent.MOUSE_MOVE, doDrag);
|
266
|
+
}
|
267
|
+
|
268
|
+
private function doDrag(event : MouseEvent) : void {
|
269
|
+
x = parent.mouseX - clickedPoint.x - anchor.x;
|
270
|
+
y = parent.mouseY - clickedPoint.y - anchor.y;
|
271
|
+
event.updateAfterEvent();
|
272
|
+
}
|
273
|
+
|
274
|
+
override public function stopDrag() : void {
|
275
|
+
if(!stage) return;
|
276
|
+
stage.removeEventListener(MouseEvent.MOUSE_MOVE, doDrag);
|
277
|
+
|
278
|
+
}
|
279
|
+
public function showLayering(e : Event = null): void{
|
280
|
+
// stage.displayState = StageDisplayState.FULL_SCREEN;
|
281
|
+
for (var i : int = 0; i < numChildren; i++) {
|
282
|
+
var child : ViewBase = getChildAt(i) as ViewBase;
|
283
|
+
child.z = -40 * i;
|
284
|
+
if(child.graphics){
|
285
|
+
child.visible = true;
|
286
|
+
child.graphics.lineStyle(1,0xFFFFFF);
|
287
|
+
child.graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
|
288
|
+
child.text(child.toString(),"Overlay").y = stage.stageHeight;
|
289
|
+
}
|
290
|
+
}
|
291
|
+
addEventListener(MouseEvent.MOUSE_WHEEL, zoomInOut);
|
292
|
+
z = 70 * numChildren;
|
293
|
+
y = 200;
|
294
|
+
rotationX = -45;
|
295
|
+
//rotationZ = 45;
|
296
|
+
// graphics.beginFill(0xFFFFFF);
|
297
|
+
|
298
|
+
graphics.lineStyle(1,0xFFFFFF);
|
299
|
+
graphics.drawRect(0, 0, stage.stageWidth, stage.stageHeight);
|
300
|
+
//graphics.drawRect(-5000, -5000, 10000, 10000);
|
301
|
+
}
|
302
|
+
|
303
|
+
private function zoomInOut(event : MouseEvent) : void {
|
304
|
+
if(event.shiftKey){
|
305
|
+
x += event.delta * 10;
|
306
|
+
}else{
|
307
|
+
var newScale : Number = scaleX + event.delta * 0.01;
|
308
|
+
scaleX = scaleY = scaleZ = newScale;
|
309
|
+
}
|
310
|
+
}
|
311
|
+
public function adjustStyle(field : TextField, styleName : String, options : Object) : void {
|
312
|
+
var style : Typography = new Typography(styleName);
|
313
|
+
for (var i : String in options) {
|
314
|
+
style[i] = options[i];
|
315
|
+
}
|
316
|
+
field.setTextFormat(style.getTextFormat());
|
317
|
+
field.defaultTextFormat = style.getTextFormat();
|
318
|
+
}
|
319
|
+
public function bringToFront(view : DisplayObject) : void {
|
320
|
+
swapChildren(view, getChildAt(numChildren-1));
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|