Skip to content

Commit 89a04c8

Browse files
author
as
committed
performance fixes
1 parent 8830a57 commit 89a04c8

File tree

8 files changed

+187
-72
lines changed

8 files changed

+187
-72
lines changed

bin/Falcon.swc

1.45 KB
Binary file not shown.

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

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

273273
public function applyAlignment():void { }
274274
public function get isSensitiveToParent(): Boolean { return false; }
275-
public function set isSensitiveToParent(value:Boolean): void {}
275+
public function setSensitiveToParent(count:uint):void {}
276276

277277
override public function dispose():void
278278
{

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

Lines changed: 42 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@ package com.hendrix.feathers.controls.flex
5858
private var _id: String = null;
5959

6060
protected var _backgroundSkin: DisplayObject = null;
61+
62+
protected var _breakParentSensitivityAfter: Number = 5;
6163

6264
/**
6365
* flex comp implementation. extend this class to use it.
@@ -127,7 +129,7 @@ package com.hendrix.feathers.controls.flex
127129
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
128130
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;
129131

130-
var fixY:Number = (parentHeightDop == parent) ? 0 : parentHeightDop.y;
132+
var fixY: Number = (parentHeightDop == parent) ? 0 : parentHeightDop.y;
131133

132134
if(!parentHeightDop || !parentWidthDop)
133135
throw new Error("no parent or parent override found!!");
@@ -140,7 +142,6 @@ package com.hendrix.feathers.controls.flex
140142
if(!(parentHeightDop as IFeathersControl).isCreated)
141143
(parentHeightDop as IFeathersControl).validate();
142144

143-
144145
var w: Number = actualWidth;
145146
var h: Number = actualHeight;
146147

@@ -189,7 +190,7 @@ package com.hendrix.feathers.controls.flex
189190

190191
public function applyAlignment():void
191192
{
192-
var child:DisplayObject = null;
193+
var child: DisplayObject = null;
193194

194195
for(var ix:uint = 0; ix < numChildren; ix++)
195196
{
@@ -231,9 +232,11 @@ package com.hendrix.feathers.controls.flex
231232
child.y = 0;
232233
break;
233234
}
235+
234236
}
235237

236238
}
239+
237240
}
238241

239242
// layout
@@ -358,10 +361,14 @@ package com.hendrix.feathers.controls.flex
358361
return _isSensitiveToParent;
359362
}
360363

361-
public function set isSensitiveToParent(value:Boolean):void
364+
public function setSensitiveToParent(count:uint):void
362365
{
363-
_isSensitiveToParent = value;
366+
_breakParentSensitivityAfter = count;
367+
_isSensitiveToParent = count==0 ? false : true;
364368

369+
if(!_isSensitiveToParent)
370+
return;
371+
365372
if(isCreated)
366373
internal_parent_observer();
367374
}
@@ -376,7 +383,8 @@ package com.hendrix.feathers.controls.flex
376383
{
377384
super.initialize();
378385

379-
internal_parent_observer();
386+
if(_isSensitiveToParent)
387+
internal_parent_observer();
380388

381389
if(_backgroundSkin)
382390
addChildAt(_backgroundSkin, 0);
@@ -401,20 +409,26 @@ package com.hendrix.feathers.controls.flex
401409
validateBackground();
402410
}
403411

404-
protected function internal_parent_observer():void {
405-
if(_isSensitiveToParent) {
406-
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
407-
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;
408-
409-
if(parentHeightDop == parentWidthDop) {
410-
}
411-
else {
412-
if(parentHeightDop)
412+
protected function internal_parent_observer(on: Boolean = true):void {
413+
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
414+
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;
415+
416+
if(parentHeightDop == parentWidthDop) {
417+
}
418+
else {
419+
if(parentHeightDop) {
420+
if(on)
413421
parentHeightDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
422+
else
423+
parentHeightDop.removeEventListener(FeathersEventType.RESIZE, onParentResized);
414424
}
415-
416-
if(parentWidthDop)
425+
}
426+
427+
if(parentWidthDop) {
428+
if(on)
417429
parentWidthDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
430+
else
431+
parentWidthDop.removeEventListener(FeathersEventType.RESIZE, onParentResized);
418432
}
419433
}
420434

@@ -424,10 +438,19 @@ package com.hendrix.feathers.controls.flex
424438

425439
applyAlignment();
426440
}
427-
441+
428442
private function onParentResized():void
429443
{
430-
invalidate(INVALIDATION_FLAG_SIZE);
444+
if(_breakParentSensitivityAfter <= 0) {
445+
internal_parent_observer(false);
446+
447+
return;
448+
}
449+
450+
_breakParentSensitivityAfter -= 1;
451+
452+
trace("onParentResized::" + _breakParentSensitivityAfter);
453+
invalidate(INVALIDATION_FLAG_SIZE);
431454
}
432455

433456
private function isParentDependant():void

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

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ package com.hendrix.feathers.controls.flex
5757

5858
private var _id: String = null;
5959

60-
private var _isSensitiveToParent: Boolean = false;
60+
private var _isSensitiveToParent: Boolean = true;
61+
protected var _breakParentSensitivityAfter: Number = 5;
6162

6263
/**
6364
* resizes font size according to width/height. right now only supports single line labels.<br>
@@ -273,38 +274,60 @@ package com.hendrix.feathers.controls.flex
273274

274275
public function applyAlignment():void { }
275276
public function get isSensitiveToParent(): Boolean { return false; }
276-
public function set isSensitiveToParent(value:Boolean): void { }
277-
278-
override protected function initialize():void
277+
public function setSensitiveToParent(count:uint):void
279278
{
280-
super.initialize();
279+
_breakParentSensitivityAfter = count;
280+
_isSensitiveToParent = count==0 ? false : true;
281281

282-
if(_isSensitiveToParent) {
283-
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestor() as DisplayObject;
284-
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestor() as DisplayObject;
285-
286-
if(parentHeightDop == parentWidthDop) {
287-
}
288-
else {
289-
if(parentHeightDop)
282+
if(!_isSensitiveToParent)
283+
return;
284+
285+
if(isCreated)
286+
internal_parent_observer();
287+
}
288+
289+
protected function internal_parent_observer(on:Boolean = true):void {
290+
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
291+
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;
292+
293+
if(parentHeightDop == parentWidthDop) {
294+
}
295+
else {
296+
if(parentHeightDop) {
297+
if(on)
290298
parentHeightDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
299+
else
300+
parentHeightDop.removeEventListener(FeathersEventType.RESIZE, onParentResized);
291301
}
292-
293-
if(parentWidthDop)
302+
}
303+
304+
if(parentWidthDop) {
305+
if(on)
294306
parentWidthDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
295-
307+
else
308+
parentWidthDop.removeEventListener(FeathersEventType.RESIZE, onParentResized);
296309
}
297-
298-
if(_bg)
299-
addChildAt(_bg, 0);
300310
}
301311

302312
private function onParentResized():void
303313
{
304-
invalidate(INVALIDATION_FLAG_SIZE);
314+
if(_breakParentSensitivityAfter-- == 0)
315+
internal_parent_observer(false);
316+
317+
invalidate(INVALIDATION_FLAG_SIZE);
305318
}
306-
307319

320+
override protected function initialize():void
321+
{
322+
super.initialize();
323+
324+
if(_isSensitiveToParent)
325+
internal_parent_observer();
326+
327+
if(_bg)
328+
addChildAt(_bg, 0);
329+
}
330+
308331
override protected function draw():void
309332
{
310333
var sizeInvalid: Boolean = isInvalid(INVALIDATION_FLAG_SIZE);
@@ -422,6 +445,29 @@ package com.hendrix.feathers.controls.flex
422445
if(!isNaN(_right))
423446
x = parentWidthDop.width - (w + _right);
424447
}
448+
449+
private function getValidAncestorHeight():DisplayObject
450+
{
451+
var validParent: DisplayObject = parent;
452+
453+
while(validParent && !validParent.height) {
454+
validParent = validParent.parent;
455+
}
456+
457+
return validParent;
458+
}
425459

460+
private function getValidAncestorWidth():DisplayObject
461+
{
462+
var validParent: DisplayObject = parent;
463+
464+
while(validParent && !validParent.width) {
465+
validParent = validParent.parent;
466+
}
467+
468+
return validParent;
469+
}
470+
426471
}
472+
427473
}

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

Lines changed: 40 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ package com.hendrix.feathers.controls.flex
4343
private var _horizontalAlign: String = null;
4444
private var _verticalAlign: String = null;
4545

46-
private var _isSensitiveToParent: Boolean = false;
47-
46+
private var _isSensitiveToParent: Boolean = true;
47+
private var _breakParentSensitivityAfter: Number = 5;
48+
4849
private var _id: String = null;
4950

5051
/**
@@ -303,9 +304,16 @@ package com.hendrix.feathers.controls.flex
303304
}
304305

305306
public function get isSensitiveToParent():Boolean { return _isSensitiveToParent; }
306-
public function set isSensitiveToParent(value:Boolean):void
307+
public function setSensitiveToParent(count:uint):void
307308
{
308-
_isSensitiveToParent = value;
309+
_breakParentSensitivityAfter = count;
310+
_isSensitiveToParent = count==0 ? false : true;
311+
312+
if(!_isSensitiveToParent)
313+
return;
314+
315+
if(isCreated)
316+
internal_parent_observer();
309317
}
310318

311319
public function get id():String { return _id; }
@@ -314,21 +322,35 @@ package com.hendrix.feathers.controls.flex
314322
_id = value;
315323
}
316324

325+
protected function internal_parent_observer(on:Boolean = true):void {
326+
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
327+
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;
328+
329+
if(parentHeightDop == parentWidthDop) {
330+
}
331+
else {
332+
if(parentHeightDop) {
333+
if(on)
334+
parentHeightDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
335+
else
336+
parentHeightDop.removeEventListener(FeathersEventType.RESIZE, onParentResized);
337+
}
338+
}
339+
340+
if(parentWidthDop) {
341+
if(on)
342+
parentWidthDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
343+
else
344+
parentWidthDop.removeEventListener(FeathersEventType.RESIZE, onParentResized);
345+
}
346+
}
347+
317348
override protected function initialize():void
318349
{
319350
super.initialize();
320351

321-
if(_isSensitiveToParent) {
322-
var parentWidthDop: DisplayObject = _relativeCalcWidthParent ? _relativeCalcWidthParent as DisplayObject : getValidAncestorWidth() as DisplayObject;
323-
var parentHeightDop: DisplayObject = _relativeCalcHeightParent ? _relativeCalcHeightParent as DisplayObject : getValidAncestorHeight() as DisplayObject;
324-
325-
if(parentHeightDop == parentWidthDop)
326-
parentWidthDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
327-
else {
328-
parentWidthDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
329-
parentHeightDop.addEventListener(FeathersEventType.RESIZE, onParentResized);
330-
}
331-
}
352+
if(_isSensitiveToParent)
353+
internal_parent_observer();
332354
}
333355

334356
override protected function draw():void
@@ -351,6 +373,9 @@ package com.hendrix.feathers.controls.flex
351373

352374
private function onParentResized():void
353375
{
376+
if(_breakParentSensitivityAfter-- == 0)
377+
internal_parent_observer(false);
378+
354379
invalidate(INVALIDATION_FLAG_SIZE);
355380
}
356381

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,14 @@ package com.hendrix.feathers.controls.flex
4747

4848
private var _isSensitiveToParent: Boolean = false;
4949

50+
public function setSensitiveToParent(count:uint):void
51+
{
52+
// TODO Auto Generated method stub
53+
54+
}
55+
56+
protected var _breakParentSensitivityAfter: Number = 5;
57+
5058
private var _id: String = null;
5159

5260
// invalidation flags

0 commit comments

Comments
 (0)