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,296 @@
|
|
1
|
+
package com.lbi.mvc.collection {
|
2
|
+
use namespace AS3;
|
3
|
+
import com.lbi.mvc.model.EventMapper;
|
4
|
+
import com.lbi.mvc.model.IEventMapper;
|
5
|
+
|
6
|
+
import flash.events.Event;
|
7
|
+
public dynamic class Collection extends Array implements IEventMapper{
|
8
|
+
public static var CHANGED : String = "changed";
|
9
|
+
private function dispatchChanged():void {event_mapper.dispatchEvent(new Event(CHANGED));}
|
10
|
+
|
11
|
+
public static var INCREASED : String = "increased";
|
12
|
+
private function dispatchIncreased():void {event_mapper.dispatchEvent(new Event(INCREASED));}
|
13
|
+
|
14
|
+
public static var DECREASED : String = "decreased";
|
15
|
+
private function dispatchDecreased():void {event_mapper.dispatchEvent(new Event(DECREASED));}
|
16
|
+
|
17
|
+
public static var CHANGED_SIZE : String = "changed_size";
|
18
|
+
private function dispatchChangedSize():void {event_mapper.dispatchEvent(new Event(CHANGED_SIZE));}
|
19
|
+
|
20
|
+
public var event_mapper : EventMapper;
|
21
|
+
|
22
|
+
private var __index:Number;
|
23
|
+
private var __previous_index:Number = 0;
|
24
|
+
|
25
|
+
private function get _index():Number{
|
26
|
+
return __index;
|
27
|
+
}
|
28
|
+
private function set _index(v:Number):void{
|
29
|
+
__previous_index = __index;
|
30
|
+
__index = v;
|
31
|
+
_current = this[__index];
|
32
|
+
}
|
33
|
+
|
34
|
+
private var __current:Object;
|
35
|
+
private function get _current():Object{
|
36
|
+
return __current;
|
37
|
+
}
|
38
|
+
private function set _current(v:Object):void{
|
39
|
+
__current = v;
|
40
|
+
try{
|
41
|
+
__current.select();
|
42
|
+
}catch(e : Error){
|
43
|
+
throw new Error("You probably need to make " + __current + " extend Selectable. " + e);
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
public var loop : Boolean;
|
48
|
+
|
49
|
+
private var __id__ : Number;
|
50
|
+
private static var __next_id__ : Number = 0;
|
51
|
+
function Collection(...$init_items){//$array: Array,$loop:Boolean) {
|
52
|
+
super();
|
53
|
+
//importArray($array);
|
54
|
+
//loop = $loop;
|
55
|
+
event_mapper = new EventMapper();
|
56
|
+
//EventMapper.initialize(this);
|
57
|
+
__id__ = __next_id__++;
|
58
|
+
if($init_items && $init_items[0]) {
|
59
|
+
for (var i : Number = 0; i < $init_items[0].length; i++) {
|
60
|
+
var item:Object = $init_items[0][i];
|
61
|
+
add(item);
|
62
|
+
}
|
63
|
+
}
|
64
|
+
}
|
65
|
+
public function selectFirst() :void{
|
66
|
+
select(first());
|
67
|
+
}
|
68
|
+
/**
|
69
|
+
* Copies a normal array into this collection.
|
70
|
+
*/
|
71
|
+
public function importArray($array : Array) :void{
|
72
|
+
while(length>0) pop();
|
73
|
+
for (var i : Number = 0; i < $array.length; i++) {
|
74
|
+
push($array[i]);
|
75
|
+
}
|
76
|
+
}
|
77
|
+
/**
|
78
|
+
* Returns currently selected item
|
79
|
+
*/
|
80
|
+
public function current() : Object {
|
81
|
+
//if(!_current) Log.warn("nothing is yet selected in " + this);
|
82
|
+
return _current;
|
83
|
+
}
|
84
|
+
public function previouslySelected() : Object{
|
85
|
+
return this[getPreviousIndex()];
|
86
|
+
}
|
87
|
+
public function hasNext() : Boolean {
|
88
|
+
return _index+1 < length && length > 0;
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* If there is another item in the collection after the current (or the collection is looped) then
|
92
|
+
* this method selects the next item and dispatches Collection.INCREASED, then Collection.CHANGED
|
93
|
+
* The selected item conventionally dispatches SELECTED and DESELECTED events, encouraged via the use of the ISelectable interface.
|
94
|
+
*/
|
95
|
+
public function next() : void {
|
96
|
+
if(!hasNext() && !loop) return;
|
97
|
+
ISelectable(current()).deselect();
|
98
|
+
if(hasNext()){
|
99
|
+
_index++;
|
100
|
+
dispatchIncreased();
|
101
|
+
}
|
102
|
+
else{
|
103
|
+
_index = 0;
|
104
|
+
}
|
105
|
+
dispatchChanged();
|
106
|
+
}
|
107
|
+
|
108
|
+
public function hasPrev() : Boolean {
|
109
|
+
return _index > 0;
|
110
|
+
}
|
111
|
+
/**
|
112
|
+
* If there is another item in the collection before the current (or the collection is looped) then
|
113
|
+
* this method selects the previous item and dispatches Collection.DECREASED, then Collection.CHANGED.
|
114
|
+
* The selected item conventionally dispatches SELECTED and DESELECTED events, encouraged via the use of the ISelectable interface.
|
115
|
+
*/
|
116
|
+
public function previous() : void {
|
117
|
+
if(!hasPrev() && !loop) return;
|
118
|
+
ISelectable(current()).deselect();
|
119
|
+
if(hasPrev()){
|
120
|
+
_index --;
|
121
|
+
dispatchDecreased();
|
122
|
+
}
|
123
|
+
else{
|
124
|
+
_index = length-1;
|
125
|
+
}
|
126
|
+
dispatchChanged();
|
127
|
+
}
|
128
|
+
/**
|
129
|
+
* selects the required item by reference.
|
130
|
+
* This is useful when you have a button in your view that holds a reference to an item model.
|
131
|
+
* The view can simply call collection.select(model) and the collection will be updated.
|
132
|
+
*/
|
133
|
+
public function select($item:Object):void{
|
134
|
+
if(current()) ISelectable(current()).deselect();
|
135
|
+
for (var i : Number = 0; i < this.length; i++) {
|
136
|
+
var item : Object = this[i];
|
137
|
+
if(item === $item) {
|
138
|
+
_index = i; // selects the current item
|
139
|
+
}
|
140
|
+
}
|
141
|
+
dispatchChanged();
|
142
|
+
}
|
143
|
+
/*
|
144
|
+
* Sets selection to null
|
145
|
+
*/
|
146
|
+
public function deselect():void{
|
147
|
+
if(current()) ISelectable(current()).deselect();
|
148
|
+
__index = NaN;
|
149
|
+
__current = null;
|
150
|
+
//dispatchChanged();
|
151
|
+
}
|
152
|
+
|
153
|
+
/**
|
154
|
+
* Removes an item from the collection
|
155
|
+
*/
|
156
|
+
public function remove($item:Object) : Object{
|
157
|
+
for (var i : Number = 0; i < this.length; i++) {
|
158
|
+
var item:Object = this[i];
|
159
|
+
if(item===$item) {
|
160
|
+
AS3::splice(i,1);
|
161
|
+
// _index = getIndex(current());
|
162
|
+
dispatchChangedSize();
|
163
|
+
return item;
|
164
|
+
}
|
165
|
+
}
|
166
|
+
return null;
|
167
|
+
}
|
168
|
+
/**
|
169
|
+
* finds (without selecting) an item in the array based on the object reference.
|
170
|
+
*/
|
171
|
+
public function find($item:Object) : Object{
|
172
|
+
for (var i : Number = 0; i < this.length; i++) {
|
173
|
+
var item:Object = this[i];
|
174
|
+
if(item===$item) {
|
175
|
+
return item;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
return null;
|
179
|
+
}
|
180
|
+
public function first() : Object{
|
181
|
+
return this[0];
|
182
|
+
}
|
183
|
+
public function last() : Object{
|
184
|
+
return this[length-1];
|
185
|
+
}
|
186
|
+
|
187
|
+
public function getCurrentIndex() :Number{
|
188
|
+
return _index;
|
189
|
+
}
|
190
|
+
/**
|
191
|
+
* Returns the index of the specified item in this array.
|
192
|
+
*/
|
193
|
+
public function getIndex($item:Object) : Number{
|
194
|
+
for (var i : Number = 0; i < this.length; i++) {
|
195
|
+
var item:Object = this[i];
|
196
|
+
if(item==$item) return i;
|
197
|
+
}
|
198
|
+
return Number.NaN;
|
199
|
+
//Log.error("Couldn't find item " + $item + " in Collection " + this);
|
200
|
+
}
|
201
|
+
public function toString() :String{
|
202
|
+
var result : String = "[Collection id:" + __id__ ;
|
203
|
+
for (var i : Number = 0; i < length; i++) {
|
204
|
+
var item:Object = this[i];
|
205
|
+
result += item.toString() + ",";
|
206
|
+
}
|
207
|
+
return result +"]";
|
208
|
+
}
|
209
|
+
|
210
|
+
public function registerEvents(view : Object, events : Array) : void {
|
211
|
+
event_mapper.registerEvents(view, events);
|
212
|
+
}
|
213
|
+
|
214
|
+
public function findByProperty($property : String, value : Object) : Object {
|
215
|
+
for (var i : Number = 0; i < this.length; i++) {
|
216
|
+
var item:Object = this[i];
|
217
|
+
if(item[$property]==value) return item;
|
218
|
+
}
|
219
|
+
return null;
|
220
|
+
}
|
221
|
+
|
222
|
+
public function findByExactProperty($property : String, value : Object) : Object {
|
223
|
+
for (var i : Number = 0; i < this.length; i++) {
|
224
|
+
var item:Object = this[i];
|
225
|
+
if(item[$property]===value) return item;
|
226
|
+
}
|
227
|
+
return null;
|
228
|
+
}
|
229
|
+
public function append(collection:Collection) : void{
|
230
|
+
for (var i : Number = 0; i < collection.length; i++) {
|
231
|
+
var item:Object = collection[i];
|
232
|
+
push(item);
|
233
|
+
}
|
234
|
+
}
|
235
|
+
|
236
|
+
public function push(value:Object):Number{
|
237
|
+
var result : Number = super.push(value);
|
238
|
+
dispatchChangedSize();
|
239
|
+
return result;
|
240
|
+
}
|
241
|
+
public function add(value:Object) : Number{
|
242
|
+
var result : Number = super.push(value);
|
243
|
+
dispatchChangedSize();
|
244
|
+
return result;
|
245
|
+
}
|
246
|
+
|
247
|
+
public function getPreviousIndex() : Number {
|
248
|
+
return __previous_index;
|
249
|
+
}
|
250
|
+
public function clone() : Collection{
|
251
|
+
return new Collection(this);
|
252
|
+
}
|
253
|
+
public function reverse() : Collection{
|
254
|
+
return new Collection(super. reverse());
|
255
|
+
}
|
256
|
+
|
257
|
+
public function dispatchEvent(event : Event) : Boolean {
|
258
|
+
return event_mapper.dispatchEvent(event);
|
259
|
+
}
|
260
|
+
|
261
|
+
public function hasEventListener(type : String) : Boolean {
|
262
|
+
return event_mapper.hasEventListener(type);
|
263
|
+
}
|
264
|
+
|
265
|
+
public function willTrigger(type : String) : Boolean {
|
266
|
+
return event_mapper.willTrigger(type);
|
267
|
+
}
|
268
|
+
|
269
|
+
public function removeEventListener(type : String, listener : Function, useCapture : Boolean = false) : void {
|
270
|
+
event_mapper.removeEventListener(type, listener);
|
271
|
+
}
|
272
|
+
|
273
|
+
public function addEventListener(type : String, listener : Function, useCapture : Boolean = false, priority : int = 0, useWeakReference : Boolean = false) : void {
|
274
|
+
event_mapper.addEventListener(type, listener,false,0,true);
|
275
|
+
}
|
276
|
+
|
277
|
+
public function unregisterEvents(view : Object, events : Array) : void {
|
278
|
+
event_mapper.unregisterEvents(view, events);
|
279
|
+
}
|
280
|
+
// override public function toString() : String {
|
281
|
+
// return "[Collection" + join(",") + "]";
|
282
|
+
// }
|
283
|
+
public function findAll(query : String) : Collection {
|
284
|
+
var results : Collection = new Collection();
|
285
|
+
try{
|
286
|
+
for (var i : int = 0; i < this.length; i++) {
|
287
|
+
var item : Matchable = this[i];
|
288
|
+
if(item.matches(query)) results.add(item);
|
289
|
+
}
|
290
|
+
} catch(e :Error){
|
291
|
+
throw new Error("You probably need to make " + this[0] + " implement Matchable. "+ e);
|
292
|
+
}
|
293
|
+
return results;
|
294
|
+
}
|
295
|
+
}
|
296
|
+
}
|
@@ -0,0 +1,10 @@
|
|
1
|
+
package com.lbi.mvc.collection {
|
2
|
+
/**
|
3
|
+
* @author michaelforrest
|
4
|
+
*/
|
5
|
+
public interface ISearchable {
|
6
|
+
function findByProperty($property : String, $value : Object) : Object;
|
7
|
+
function findByValue($value : Object) : Object;
|
8
|
+
//function push(object : Object) : Number;
|
9
|
+
}
|
10
|
+
}
|
@@ -0,0 +1,56 @@
|
|
1
|
+
package com.lbi.mvc.collection {
|
2
|
+
|
3
|
+
/**
|
4
|
+
LBi Useful ActionScript 2 Library
|
5
|
+
Copyright (C) 2007 LBi / Michael Forrest
|
6
|
+
|
7
|
+
This library is free software; you can redistribute it and/or
|
8
|
+
modify it under the terms of the GNU Lesser General Public
|
9
|
+
License as published by the Free Software Foundation; either
|
10
|
+
version 2.1 of the License, or (at your option) any later version.
|
11
|
+
|
12
|
+
This library is distributed in the hope that it will be useful,
|
13
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
15
|
+
Lesser General Public License for more details.
|
16
|
+
|
17
|
+
You should have received a copy of the GNU Lesser General Public
|
18
|
+
License along with this library; if not, write to the Free Software
|
19
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
20
|
+
*/
|
21
|
+
use namespace AS3;
|
22
|
+
public dynamic class Searchable extends Array implements ISearchable{
|
23
|
+
|
24
|
+
public static function initialize($searchable : ISearchable) : void {
|
25
|
+
var instance : Searchable = new Searchable([]);
|
26
|
+
$searchable["findByProperty"] = instance.findByProperty;
|
27
|
+
$searchable["findByValue"] = instance.findByValue;
|
28
|
+
}
|
29
|
+
|
30
|
+
public function Searchable($array: Array ) {
|
31
|
+
for (var i : Number = 0; i < $array.length; i++) {
|
32
|
+
var item:Object = $array[i];
|
33
|
+
push(item);
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
public function findByProperty($property : String, $value : Object) : Object {
|
38
|
+
for (var i : Number = 0; i < this.length; i++) {
|
39
|
+
var item:Object = this[i];
|
40
|
+
if(item[$property]==$value) return item;
|
41
|
+
}
|
42
|
+
return null;
|
43
|
+
}
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
public function findByValue($value : Object) : Object {
|
48
|
+
for (var i : Number = 0; i < this.length; i++) {
|
49
|
+
var item:Object = this[i];
|
50
|
+
if(item==$value) return item;
|
51
|
+
}
|
52
|
+
return null;
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
package com.lbi.mvc.collection {
|
2
|
+
import flash.events.Event;
|
3
|
+
|
4
|
+
import com.lbi.mvc.model.EventMapper;
|
5
|
+
public class Selectable extends EventMapper implements ISelectable{
|
6
|
+
|
7
|
+
public static const SELECTED : String = "selected";
|
8
|
+
|
9
|
+
// Gonna see how easy this makes testing!
|
10
|
+
public static var lastSelectedThing : Selectable;
|
11
|
+
|
12
|
+
|
13
|
+
|
14
|
+
|
15
|
+
protected function dispatchSelected():void {dispatchEvent(new Event(SELECTED));}
|
16
|
+
public static const DESELECTED : String = "deselected";
|
17
|
+
|
18
|
+
protected function dispatchDeselected():void {dispatchEvent( new Event(DESELECTED));}
|
19
|
+
|
20
|
+
protected var __selected__ : Boolean = false;
|
21
|
+
|
22
|
+
public function Selectable() {
|
23
|
+
}
|
24
|
+
|
25
|
+
public function select() : void {
|
26
|
+
if(__selected__) return;
|
27
|
+
__selected__ = true;
|
28
|
+
lastSelectedThing = this;
|
29
|
+
dispatchSelected();
|
30
|
+
}
|
31
|
+
|
32
|
+
public function deselect() : void {
|
33
|
+
__selected__ = false;
|
34
|
+
dispatchDeselected();
|
35
|
+
}
|
36
|
+
|
37
|
+
public function isSelected() : Boolean {
|
38
|
+
return __selected__;
|
39
|
+
}
|
40
|
+
public static function initialize(object:ISelectable) : void{
|
41
|
+
var inst : Selectable = new Selectable();
|
42
|
+
//object["__selected__"] = inst["__selected__"];
|
43
|
+
object["select"] = inst.select;
|
44
|
+
object["deselect"] = inst.deselect;
|
45
|
+
object["isSelected"] = inst.isSelected;
|
46
|
+
}
|
47
|
+
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
package com.lbi.mvc.helper {
|
2
|
+
import flash.utils.ByteArray;
|
3
|
+
/**
|
4
|
+
* @author michaelforrest
|
5
|
+
*/
|
6
|
+
public class Cloner {
|
7
|
+
// from kirupa
|
8
|
+
public static function clone(source:Object):* {
|
9
|
+
var copier:ByteArray = new ByteArray();
|
10
|
+
copier.writeObject(source);
|
11
|
+
copier.position = 0;
|
12
|
+
return(copier.readObject());
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
@@ -0,0 +1,194 @@
|
|
1
|
+
package com.lbi.mvc.helper {
|
2
|
+
import flash.display.DisplayObject;
|
3
|
+
import flash.display.Sprite;
|
4
|
+
import flash.geom.Rectangle;
|
5
|
+
import flash.text.TextField;
|
6
|
+
import flash.text.TextFormat;
|
7
|
+
/**
|
8
|
+
LBi Useful ActionScript 3 Library (ported from AS2 Library equivalent)
|
9
|
+
Copyright (C) 2007 LBi / Michael Forrest
|
10
|
+
|
11
|
+
This library is free software; you can redistribute it and/or
|
12
|
+
modify it under the terms of the GNU Lesser General Public
|
13
|
+
License as published by the Free Software Foundation; either
|
14
|
+
version 2.1 of the License, or (at your option) any later version.
|
15
|
+
|
16
|
+
This library is distributed in the hope that it will be useful,
|
17
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
19
|
+
Lesser General Public License for more details.
|
20
|
+
|
21
|
+
You should have received a copy of the GNU Lesser General Public
|
22
|
+
License along with this library; if not, write to the Free Software
|
23
|
+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
24
|
+
* This class eschews the usual naming conventions in favour of something
|
25
|
+
* that looks a bit more like CSS. Override the Defaults() method to set the defaults.
|
26
|
+
* <pre>
|
27
|
+
* class app.helpers.Typography extends TypographyBase {
|
28
|
+
|
29
|
+
private var WHITE : Number = 0xFFFFFF;
|
30
|
+
|
31
|
+
private var ORANGE : Number = 0xF68B1E;
|
32
|
+
|
33
|
+
function Typography(style:String) {
|
34
|
+
super(style);
|
35
|
+
}
|
36
|
+
private function Defaults() : void{
|
37
|
+
font = Linkages.ARIAL;
|
38
|
+
colour = WHITE;
|
39
|
+
}
|
40
|
+
private function H1() : void{
|
41
|
+
font_size = 24;
|
42
|
+
}
|
43
|
+
private function P() : void{
|
44
|
+
font_size = 12;
|
45
|
+
}
|
46
|
+
private function Footer() : void{
|
47
|
+
font_size = 16;
|
48
|
+
}
|
49
|
+
private function ItemHeading() : void{
|
50
|
+
font_size = 16;
|
51
|
+
bold = true;
|
52
|
+
colour = ORANGE;
|
53
|
+
}
|
54
|
+
|
55
|
+
}
|
56
|
+
* </pre>
|
57
|
+
*
|
58
|
+
*/
|
59
|
+
public class TypographyBase {
|
60
|
+
|
61
|
+
public function TypographyBase(style:String = "") {
|
62
|
+
Defaults();
|
63
|
+
if(style && this[style]!=null) {
|
64
|
+
this[style]();
|
65
|
+
}
|
66
|
+
}
|
67
|
+
public function changeStyle(txt : TextField, style : Function) : void {
|
68
|
+
this[style]();
|
69
|
+
var formats:Object = getTextFieldParams();
|
70
|
+
for(var i:String in formats) txt[i] = formats[i];
|
71
|
+
|
72
|
+
var fmt:TextFormat = getTextFormat();
|
73
|
+
txt.setTextFormat(fmt);
|
74
|
+
txt.text = txt.text;
|
75
|
+
}
|
76
|
+
|
77
|
+
public function System() : void {
|
78
|
+
embed_fonts = false;
|
79
|
+
font = "_sans";
|
80
|
+
font_size = 11;
|
81
|
+
background = true;
|
82
|
+
}
|
83
|
+
|
84
|
+
public static function getSystemFont() : TypographyBase{
|
85
|
+
return new TypographyBase("System");
|
86
|
+
}
|
87
|
+
|
88
|
+
/*
|
89
|
+
* TextFormat stuff
|
90
|
+
*/
|
91
|
+
public var font_size : Number = 12;
|
92
|
+
public var font : String = "Bodyfont";
|
93
|
+
public var colour : Number = 0;
|
94
|
+
public var bold : Boolean = false;
|
95
|
+
public var italic : Boolean = false;
|
96
|
+
public var underline : Boolean = false;
|
97
|
+
public var url : String = "";
|
98
|
+
public var target : String = "";
|
99
|
+
public var align : String = "left";
|
100
|
+
public var left_margin : Number = 0;
|
101
|
+
public var right_margin : Number = 0;
|
102
|
+
public var indent : Number = 0;
|
103
|
+
public var leading : Number = 0;
|
104
|
+
|
105
|
+
/*
|
106
|
+
* TextField parameters
|
107
|
+
*/
|
108
|
+
public var auto_size : String = "left";
|
109
|
+
public var background : Boolean = false;
|
110
|
+
//public var html : Boolean = false;
|
111
|
+
public var word_wrap : Boolean = true;
|
112
|
+
public var multiline : Boolean = true;
|
113
|
+
public var condense_white : Boolean = true;
|
114
|
+
public var border : Boolean = false;
|
115
|
+
public var selectable : Boolean = false;
|
116
|
+
public var embed_fonts : Boolean = true;
|
117
|
+
public var type : String = "dynamic";
|
118
|
+
/**
|
119
|
+
* Flash 8 only
|
120
|
+
* Can be "normal" or "advanced".
|
121
|
+
* @see gridFitType, thickness and sharpness
|
122
|
+
*/
|
123
|
+
public var antiAliasType:String = "normal";
|
124
|
+
/**
|
125
|
+
* Flash 8 only
|
126
|
+
* Can be "none", "pixel" or "subpixel"
|
127
|
+
*/
|
128
|
+
public var gridFitType:String = "none";
|
129
|
+
/**
|
130
|
+
* Flash 8 only
|
131
|
+
* In range -200 to 200
|
132
|
+
* The thickness of the glyph edges in this TextField
|
133
|
+
* instance. This property applies only
|
134
|
+
* when antiAliasType() is set to "advanced".
|
135
|
+
*/
|
136
|
+
public var thickness:Number = 0;
|
137
|
+
public var max_chars : Number;
|
138
|
+
/**
|
139
|
+
* Flash 8 only
|
140
|
+
* The range for sharpness is a number from -400 to 400.
|
141
|
+
*/
|
142
|
+
public var sharpness:Number = 0;
|
143
|
+
/**
|
144
|
+
* Flash 8 only
|
145
|
+
* The amount of space that is uniformly distributed between characters.
|
146
|
+
*/
|
147
|
+
public var letterSpacing : Number = 0;
|
148
|
+
|
149
|
+
protected function Defaults() : void {
|
150
|
+
}
|
151
|
+
|
152
|
+
public function getTextFormat() : TextFormat{
|
153
|
+
var tf : TextFormat = new TextFormat(font, font_size, colour,
|
154
|
+
bold, italic, underline, url,target, align,
|
155
|
+
left_margin, right_margin, indent, leading);
|
156
|
+
tf.letterSpacing = letterSpacing;
|
157
|
+
return tf;
|
158
|
+
}
|
159
|
+
public function getTextFieldParams():Object{
|
160
|
+
var t:Object = new Object(); // TextField
|
161
|
+
t.background = background;
|
162
|
+
t.embedFonts = embed_fonts;
|
163
|
+
t.selectable = selectable;
|
164
|
+
t.border = border;
|
165
|
+
t.condenseWhite = condense_white;
|
166
|
+
t.multiline = multiline;
|
167
|
+
t.wordWrap = word_wrap;
|
168
|
+
//t.html = html;
|
169
|
+
t.autoSize = auto_size;
|
170
|
+
t.type = type;
|
171
|
+
t.antiAliasType = antiAliasType;
|
172
|
+
t.gridFitType = gridFitType;
|
173
|
+
t.thickness = thickness;
|
174
|
+
t.sharpness = sharpness;
|
175
|
+
t.maxChars = max_chars;
|
176
|
+
return t;
|
177
|
+
}
|
178
|
+
|
179
|
+
public static function createTextField(style : TypographyBase, rectangle : Rectangle) : TextField {
|
180
|
+
var txt : TextField = new TextField();
|
181
|
+
txt.x = rectangle.x;
|
182
|
+
txt.y = rectangle.y;
|
183
|
+
txt.width = rectangle.width;
|
184
|
+
txt.height = rectangle.height;
|
185
|
+
var formats:Object = style.getTextFieldParams();
|
186
|
+
for(var i:String in formats) txt[i] = formats[i];
|
187
|
+
|
188
|
+
var fmt : TextFormat = style.getTextFormat();
|
189
|
+
txt.defaultTextFormat = fmt;
|
190
|
+
txt.setTextFormat(fmt);
|
191
|
+
return txt;
|
192
|
+
}
|
193
|
+
}
|
194
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
package com.lbi.mvc.helper.preloading {
|
2
|
+
import com.lbi.mvc.model.SequentialDependencyLoader;
|
3
|
+
|
4
|
+
import flash.events.Event;
|
5
|
+
/**
|
6
|
+
* @author michaelforrest
|
7
|
+
*/
|
8
|
+
public class LoadProgressEvent extends Event {
|
9
|
+
|
10
|
+
public static const PROGRESS : String = "progress";
|
11
|
+
public var loader : SequentialDependencyLoader;
|
12
|
+
|
13
|
+
public function LoadProgressEvent(dependencyLoader : SequentialDependencyLoader) {
|
14
|
+
super(PROGRESS);
|
15
|
+
loader = dependencyLoader;
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,45 @@
|
|
1
|
+
package com.lbi.mvc.model {
|
2
|
+
import com.lbi.mvc.model.EventMapper;
|
3
|
+
import com.lbi.mvc.model.SequentialDependencyLoader;
|
4
|
+
|
5
|
+
import flash.events.Event;
|
6
|
+
import flash.events.EventDispatcher;
|
7
|
+
import flash.utils.getQualifiedClassName;
|
8
|
+
/**
|
9
|
+
* @author michaelforrest
|
10
|
+
*/
|
11
|
+
public class Application extends EventMapper {
|
12
|
+
public static var READY : String = "ready";
|
13
|
+
public function dispatchReady() : void {dispatchEvent(new Event(READY));
|
14
|
+
}
|
15
|
+
|
16
|
+
private var dependencyLoader : SequentialDependencyLoader;
|
17
|
+
|
18
|
+
protected var dependencies : Array;
|
19
|
+
|
20
|
+
public function Application() {
|
21
|
+
setup();
|
22
|
+
dependencyLoader = new SequentialDependencyLoader( dependencies);//.map(prepare));
|
23
|
+
dependencyLoader.addEventListener(SequentialDependencyLoader.READY, onXMLReady,false,0,true);
|
24
|
+
}
|
25
|
+
|
26
|
+
|
27
|
+
|
28
|
+
private function prepare(element : *, index : int, arr : Array) : EventDispatcher {
|
29
|
+
if(!element.prepare) throw new Error("Please create a prepare() : EventDispatcher {} event on class " + getQualifiedClassName(element));
|
30
|
+
return element.prepare();
|
31
|
+
}
|
32
|
+
|
33
|
+
protected function setup() : void {
|
34
|
+
dependencies = [];
|
35
|
+
}
|
36
|
+
private function onXMLReady(event : Event) : void {
|
37
|
+
afterLoaded();
|
38
|
+
dispatchReady();
|
39
|
+
}
|
40
|
+
|
41
|
+
protected function afterLoaded() : void {
|
42
|
+
}
|
43
|
+
|
44
|
+
}
|
45
|
+
}
|