Skip to content

Commit 3e513a5

Browse files
committed
Merge branch 'master' of https://github.com/HendrixString/Falcon
2 parents beac37a + 952b88e commit 3e513a5

File tree

14 files changed

+567
-20
lines changed

14 files changed

+567
-20
lines changed

.flexLibProperties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
<classEntry path="com.hendrix.feathers.controls.flex.flexTabBar.FlexTabBar"/>
5959
<classEntry path="com.hendrix.feathers.controls.textService.BidiTextField.bidi.core.DirectionalOverrideStatus"/>
6060
<classEntry path="com.hendrix.feathers.controls.utils.SAppUtils"/>
61+
<classEntry path="com.hendrix.feathers.controls.flex.MovieClipButton"/>
6162
</includeClasses>
6263
<includeResources/>
6364
<namespaceManifests/>

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,9 @@ public function startSplash(flashSpriteParent:flash.display.DisplayObjectContain
189189
layout options. great for dynamic splash screens
190190
* `BidiTextField` Bidirectional Text field with *bitmap fonts*. based on another repository i have published
191191
* `TLFLabel` Bidirectional Image text label based on `Adobe TLF`.
192+
* `HitButton` a flex button with a definable Polygon hit area.
193+
* `DragHitButton` a draggable button with ability to register objects for drop on and events.
194+
* `MovieClipButton` a flex button with `MovieClip` skin and sound and events.
192195

193196
- a set of widgets
194197
* `ListUpdateWidget` - a widget that hooks to a list to augment it with pull to refresh feature.

bin/Falcon.swc

1.58 MB
Binary file not shown.

src/com/hendrix/feathers/controls/core/BitmapLayersComposer.as

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,9 @@ package com.hendrix.feathers.controls.core
6363
private var _frameRect: Rectangle = null;
6464
private var _latestCapture: BitmapData = null;
6565

66+
private var _hasLoaded: Boolean = false;
67+
private var _disposeOnRemove: Boolean = true;
68+
6669
/**
6770
* a Flash Display Object composer of layers, Flex Style with a dataprovider<br>
6871
* can be used easily as a SplashScreen
@@ -98,8 +101,15 @@ package com.hendrix.feathers.controls.core
98101
addEventListener(Event.ADDED_TO_STAGE, onAddedToStage);
99102
}
100103

104+
public function get disposeOnRemove():Boolean { return _disposeOnRemove; }
105+
public function set disposeOnRemove(value:Boolean):void
106+
{
107+
_disposeOnRemove = value;
108+
}
109+
101110
/**
102111
* remove from display list
112+
* and dispose
103113
*
104114
*/
105115
public function remove():void
@@ -115,6 +125,17 @@ package com.hendrix.feathers.controls.core
115125
_timerDelay.start();
116126
}
117127

128+
/**
129+
* remove from display list
130+
* and dispose
131+
*
132+
*/
133+
public function removeNoDispose():void
134+
{
135+
if(_parent)
136+
_parent.removeChild(this);
137+
}
138+
118139
/**
119140
* dispose all
120141
*/
@@ -192,7 +213,7 @@ package com.hendrix.feathers.controls.core
192213
{
193214
_parent.addChild(this);
194215
}
195-
216+
196217
protected function onAddedToStage(event:Event):void
197218
{
198219
_frameRect = new Rectangle(0, 0, stage.fullScreenWidth, stage.fullScreenHeight);
@@ -202,7 +223,8 @@ package com.hendrix.feathers.controls.core
202223
_frameRect.height = _parent.height;
203224
}
204225

205-
loadSources();
226+
if(!_hasLoaded)
227+
loadSources();
206228
}
207229

208230
protected function onTimerComplete(event:TimerEvent = null):void
@@ -213,7 +235,8 @@ package com.hendrix.feathers.controls.core
213235
if(_parent)
214236
_parent.removeChild(this);
215237

216-
dispose();
238+
if(_disposeOnRemove)
239+
dispose();
217240

218241
//_parent.stage.setAspectRatio(StageAspectRatio.ANY);
219242
}
@@ -266,8 +289,10 @@ package com.hendrix.feathers.controls.core
266289
{
267290
_bmSources[ix] = new Bitmap(bitmaps[ix].bmp);
268291
}
292+
293+
layout();
269294

270-
layout();
295+
_hasLoaded = true;
271296
}
272297

273298
private function layout(id:String = null):void

src/com/hendrix/feathers/controls/core/ExtScreenNavigator.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ package com.hendrix.feathers.controls.core
6767
var item: ScreenNavigatorItem = new ScreenNavigatorItem(screen, events, props);
6868

6969
addScreen($id, item);
70-
70+
7171
return item;
7272
}
7373

Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
package com.hendrix.feathers.controls.flex
2+
{
3+
import flash.geom.Point;
4+
5+
import starling.display.DisplayObject;
6+
import starling.events.Event;
7+
import starling.events.Touch;
8+
import starling.events.TouchEvent;
9+
import starling.events.TouchPhase;
10+
11+
/**
12+
* a draggable <code>HitButton</code> with the following features
13+
* <lu>
14+
* <li/>this component is <code>HitButton</code> and draggable.
15+
* <li/>register <code>DisplayObject</code>s to detect when this object was dropped on them.
16+
* <li/>listen to <code>DROP, DROPPED_ON, DRAG</code> events.
17+
*
18+
*
19+
* @author Tomer Shalev
20+
*
21+
* @see HitButton
22+
*/
23+
public class DragHitButton extends HitButton
24+
{
25+
/**
26+
* Event for Dropping the this button
27+
*/
28+
public static const DROP: String = "drop";
29+
[Event(name="drop", type="starling.events.Event")]
30+
31+
/**
32+
* Event for Dropping this button on one of the registered DisplayObject.
33+
*/
34+
public static const DROPPED_ON: String = "droppedOn";
35+
[Event(name="droppedOn", type="starling.events.Event")]
36+
37+
/**
38+
* Event for Dragging this button.
39+
*/
40+
public static const DRAG: String = "drag";
41+
[Event(name="drag", type="starling.events.Event")]
42+
43+
/**
44+
* a helper <code>Point</code>
45+
*/
46+
private var _point_helper: Point = null;
47+
private var _isDragged: Boolean = false;
48+
49+
private var _expected_flag: Boolean = false;
50+
51+
private var callback_onComplete: Function = null;
52+
private var point_aux: Point = new Point();
53+
54+
private var _pOriginal_x: Number = NaN;
55+
private var _pOriginal_y: Number = NaN;
56+
/**
57+
* registered vector of <code>DisplayObject</code> to detect dropping on.
58+
*/
59+
private var _dop_dropped: Vector.<DisplayObject> = null;
60+
61+
public function DragHitButton()
62+
{
63+
super();
64+
65+
_dop_dropped = new Vector.<DisplayObject>();
66+
}
67+
68+
override public function set x(value:Number):void
69+
{
70+
if(isNaN(_pOriginal_x))
71+
_pOriginal_x = value;
72+
73+
super.x = value;
74+
}
75+
76+
override public function set y(value:Number):void
77+
{
78+
if(isNaN(_pOriginal_y))
79+
_pOriginal_y = value;
80+
81+
super.y = value;
82+
}
83+
84+
public function reset():void
85+
{
86+
if(!isNaN(_pOriginal_x))
87+
x = _pOriginal_x;
88+
if(!isNaN(_pOriginal_y))
89+
y = _pOriginal_y;
90+
}
91+
92+
/**
93+
* is dragged
94+
*
95+
* @return <code>true/false</code>
96+
*
97+
*/
98+
public function get isDragged():Boolean
99+
{
100+
return _isDragged;
101+
}
102+
103+
/**
104+
* add <code>DisplayObject</code> to detect this object was dropped on.
105+
*
106+
* @param dop a <code>DisplayObject</code>
107+
*
108+
*/
109+
public function registerDisplayObject(dop: DisplayObject):void
110+
{
111+
_dop_dropped.push(dop);
112+
}
113+
114+
override protected function feathersControl_addedToStageHandler(event:Event):void
115+
{
116+
super.feathersControl_addedToStageHandler(event);
117+
118+
_point_helper = _point_helper ? _point_helper : new Point();
119+
120+
addEventListener(TouchEvent.TOUCH, touchHandler);
121+
}
122+
123+
override protected function feathersControl_removedFromStageHandler(event:Event):void
124+
{
125+
super.feathersControl_removedFromStageHandler(event);
126+
127+
removeEventListener(TouchEvent.TOUCH, touchHandler);
128+
}
129+
130+
private function touchHandler(event: TouchEvent = null):void
131+
{
132+
if(event == null)
133+
return;
134+
135+
var touch: Touch = event.getTouch(stage);
136+
137+
touch.getLocation(stage, _point_helper);
138+
139+
var target: HitButton = event.target as HitButton;
140+
141+
if(touch.phase == TouchPhase.MOVED) {
142+
target.x = _point_helper.x - target.width/2;
143+
target.y = _point_helper.y - target.height/2;
144+
145+
if(hasEventListener(DRAG))
146+
dispatchEventWith(DRAG, false, _point_helper);
147+
148+
_isDragged = true;
149+
}
150+
else if(touch.phase == TouchPhase.ENDED) {
151+
if(_isDragged) {
152+
if(hasEventListener(DROP))
153+
dispatchEventWith(DROP, false, _point_helper);
154+
155+
if(hasEventListener(DROPPED_ON)) {
156+
for (var ix: int = 0; ix < _dop_dropped.length; ix++)
157+
{
158+
if(_dop_dropped[ix].getBounds(stage).containsPoint(_point_helper))
159+
dispatchEventWith(DROPPED_ON, false, {dropped: target, dropped_on: _dop_dropped[ix], pos:_point_helper});
160+
}
161+
}
162+
163+
_isDragged = false;
164+
}
165+
}
166+
else {
167+
}
168+
169+
}
170+
171+
}
172+
173+
}

src/com/hendrix/feathers/controls/flex/FlexButton.as

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ package com.hendrix.feathers.controls.flex
5858
public function FlexButton()
5959
{
6060
super();
61+
62+
_isToggle = false;
6163
}
6264

6365
/**
@@ -279,7 +281,7 @@ package com.hendrix.feathers.controls.flex
279281
_relativeCalcWidthParent = null;
280282
_relativeCalcHeightParent = null;
281283
}
282-
284+
283285
override protected function initialize():void
284286
{
285287
super.initialize();
@@ -296,7 +298,7 @@ package com.hendrix.feathers.controls.flex
296298
}
297299
}
298300
}
299-
301+
300302
protected function setupSize():void
301303
{
302304
var arIcon: Number;
@@ -392,7 +394,7 @@ package com.hendrix.feathers.controls.flex
392394
}
393395

394396
}
395-
397+
396398
override protected function draw():void
397399
{
398400
var sizeInvalid: Boolean = isInvalid(INVALIDATION_FLAG_SIZE);
@@ -407,7 +409,7 @@ package com.hendrix.feathers.controls.flex
407409

408410
super.draw();
409411
}
410-
412+
411413
private function getValidAncestorHeight():DisplayObject
412414
{
413415
var validParent: DisplayObject = parent;

src/com/hendrix/feathers/controls/flex/FlexImage.as

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ package com.hendrix.feathers.controls.flex
7878

7979
/**
8080
* source can be anything<br>
81-
* bitmap class, bitmapdata, bitmap, GfxPackage path, local path
81+
* <code>Texture, bitmap class, bitmapdata, bitmap, GfxPackage path, local path</code>
8282
*/
8383
public function get source():Object { return _source; }
8484
public function set source(value:Object):void

src/com/hendrix/feathers/controls/flex/FlexTextInput.as

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ package com.hendrix.feathers.controls.flex
113113
_textInitial = value;
114114
}
115115

116-
super.text = value;
116+
if(value == null) {
117+
super.text = _textInitial;
118+
119+
return;
120+
}
121+
122+
super.text = value;
117123
}
118124

119125
override public function get text():String
@@ -302,6 +308,7 @@ package com.hendrix.feathers.controls.flex
302308
public function set textInitial(value:String):void
303309
{
304310
_textInitial = value;
311+
305312
super.text = _textInitial;
306313
}
307314

0 commit comments

Comments
 (0)