Packageorg.openPyro.core
Classpublic class MeasurableControl
InheritanceMeasurableControl Inheritance flash.display.Sprite
SubclassesSpacer, UIControl

The Measurable control is the basic class that participates in Pyro's measurement strategy. Measurable controls understand a variety of properties like explicit height/width which is set if you set the width or height property with an actual neumerical value, or percentUnusedWidth and percentUnusedHeight which are set if the control's size is based on measurement of the parent control. Controls can also be sized using the percentWidth or percentHeight which is based on the parent's size without taking the other children in the parent under consideration. Note: As of right now percentWidth and percentHeight may not be respected by certain containers like DividedBoxes



Public Properties
 PropertyDefined by
  creationCompleteFired : Boolean
[read-only]
MeasurableControl
  displayListInvalidated : Boolean = true
Flag to mark a dirty displaylist.
MeasurableControl
  explicitWidth : Number
The height set in terms of actual pixels.
MeasurableControl
  forceInvalidateDisplayList : Boolean = false
MeasurableControl
  height : Number
Set/get the height of the control.
MeasurableControl
  includeInLayout : Boolean
Specifies whether this control participates in the layout system in OpenPyro.
MeasurableControl
  initialized : Boolean = false
Property indicates whether a control has been initialized or not.
MeasurableControl
  maximumHeight : Number
MeasurableControl
  maximumWidth : Number
MeasurableControl
  measuredHeight : Number
Set the measured height of the control.
MeasurableControl
  measuredWidth : Number
Returns the measured width after the control has been measured.
MeasurableControl
  mouseActionsDisabled : Boolean
[read-only]
MeasurableControl
  needsMeasurement : Boolean = true
Only setting percent width/heights changes the needsMeasurement flag which makes its parent container call measure on it.
MeasurableControl
  parentContainer : UIControl
MeasurableControl
  percentHeight : Number
MeasurableControl
  percentUnusedHeight : Number
Set/get the percent height.
MeasurableControl
  percentUnusedWidth : Number
Set/get the percent width.
MeasurableControl
  percentWidth : Number
MeasurableControl
  sizeInvalidated : Boolean = false
The flag to mark that the control's size has been invalidated.
MeasurableControl
  usesMeasurementStrategy : Boolean
[read-only] This property defines whether measure() will be called during validateSize() or not.
MeasurableControl
  visible : Boolean
[write-only]
MeasurableControl
  width : Number
Set/get the width of the control.
MeasurableControl
Protected Properties
 PropertyDefined by
  _creationCompleteFired : Boolean = false
MeasurableControl
  _dimensionsChanged : Boolean = true
MeasurableControl
  _explicitHeight : Number = NaN
MeasurableControl
  _explicitWidth : Number = NaN
MeasurableControl
  _maximumHeight : Number = NaN
MeasurableControl
  _maximumWidth : Number = NaN
MeasurableControl
  _measuredHeight : Number = NaN
MeasurableControl
  _measuredWidth : Number = NaN
MeasurableControl
  _mouseActionsDisabled : Boolean = false
MeasurableControl
  _parentContainer : UIControl
MeasurableControl
  _percentHeight : Number
MeasurableControl
  _percentUnusedHeight : Number
MeasurableControl
  _percentUnusedWidth : Number
MeasurableControl
  _percentWidth : Number
MeasurableControl
Public Methods
 MethodDefined by
  
MeasurableControl
  
MeasurableControl
  
Calls the queueValidateDisplayList if measure causes _dimensionsChanged to change to true.
MeasurableControl
  
doOnAdded():void
[Temp] This function is called automatically by a parent UIControl if this is created as a child of a UIControl.
MeasurableControl
  
MeasurableControl
  
Returns the explicitly defined height or the measured height computed by the measure function.
MeasurableControl
  
Returns the explicitly defined width or the measured number computed by the measure function.
MeasurableControl
  
initialize():void
This happens only once when a child is first added to any parent.
MeasurableControl
  
invalidateSize(event:PyroEvent = null):void
Marks itself dirty and waits till either the container to validateSize or validates itself at the next enterframe if it has no parent container.
MeasurableControl
  
isMouseOver(event:MouseEvent):Boolean
Utility function to check if a mouseEvent happened while the mouse was over the displayObject
MeasurableControl
  
measure():void
Measure is called during the validateSize if the needsmeasurement flag is set.
MeasurableControl
  
This function is called if the framework determines that dimensions of the control have changed.
MeasurableControl
  
MeasurableControl
  
updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void
The updateDisplayList is triggered everytime the framework determines that some event has taken place that needs the UI to be refreshed.
MeasurableControl
  
validateDisplayList(event:Event = null):void
validateDisplayList is called as a response to invalidateDisplayList.
MeasurableControl
  
validateSize():void
The validateSize function is called in response to a component declaring its size invalid (usually by calling invalidateSize()).
MeasurableControl
Protected Methods
 MethodDefined by
  
Calculates the measuredHeight property.
MeasurableControl
  
Calculates the measuredWidth property.
MeasurableControl
  
This is where the new children should be created and then added to the displaylist.
MeasurableControl
  
disableEvent(event:Event):void
MeasurableControl
  
Dispatches the UpdateComplete event
MeasurableControl
  
doQueuedValidateSize(event:Event):void
doQueueValidateSize is executed by the top level UIControl.
MeasurableControl
  
MeasurableControl
  
onAddedToParent(event:Event):void
The event listener executed when this component has been added to the parent.
MeasurableControl
Events
 EventSummaryDefined by
    MeasurableControl
    MeasurableControl
    MeasurableControl
    MeasurableControl
    MeasurableControl
    MeasurableControl
    MeasurableControl
    MeasurableControl
Property detail
_creationCompleteFiredproperty
protected var _creationCompleteFired:Boolean = false
creationCompleteFiredproperty 
creationCompleteFired:Boolean  [read-only]Implementation
    public function get creationCompleteFired():Boolean
_dimensionsChangedproperty 
protected var _dimensionsChanged:Boolean = true
displayListInvalidatedproperty 
public var displayListInvalidated:Boolean = true

Flag to mark a dirty displaylist. It basically means it is waiting for a call to updateDisplayList at some point

_explicitHeightproperty 
protected var _explicitHeight:Number = NaN
_explicitWidthproperty 
protected var _explicitWidth:Number = NaN
explicitWidthproperty 
explicitWidth:Number  [read-write]

The height set in terms of actual pixels. You do not call this function in your code. Setting the width of the control to an actual numeric value (rather than percent) calls this function Call this function only if you want to set width without calling the invalidation methods [TODO] This class should have namespace access control (pyro_internal)

Implementation
    public function get explicitWidth():Number
    public function set explicitWidth(value:Number):void
forceInvalidateDisplayListproperty 
public var forceInvalidateDisplayList:Boolean = false
heightproperty 
height:Number  [read-write]

Set/get the height of the control. If the height is set to a different value from the one the control is already at, it triggers the size invalidation cycle

Implementation
    public function get height():Number
    public function set height(value:Number):void
includeInLayoutproperty 
includeInLayout:Boolean  [read-write]

Specifies whether this control participates in the layout system in OpenPyro. For example if you have 3 UIControls sitting in a container with a HLayout layout, but the second control as the includeInLayout property set to false, the layout will not position that control.

Implementation
    public function get includeInLayout():Boolean
    public function set includeInLayout(value:Boolean):void
initializedproperty 
public var initialized:Boolean = false

Property indicates whether a control has been initialized or not. Initialization happens the first time the control is added to the parent.

_maximumHeightproperty 
protected var _maximumHeight:Number = NaN
maximumHeightproperty 
maximumHeight:Number  [read-write]Implementation
    public function get maximumHeight():Number
    public function set maximumHeight(value:Number):void
_maximumWidthproperty 
protected var _maximumWidth:Number = NaN
maximumWidthproperty 
maximumWidth:Number  [read-write]Implementation
    public function get maximumWidth():Number
    public function set maximumWidth(value:Number):void
_measuredHeightproperty 
protected var _measuredHeight:Number = NaN
measuredHeightproperty 
measuredHeight:Number  [read-write]

Set the measured height of the control. This is usually set by the same control's measure() function. If the measuredHeight is changed, the displayList is invalidated

Implementation
    public function get measuredHeight():Number
    public function set measuredHeight(value:Number):void
_measuredWidthproperty 
protected var _measuredWidth:Number = NaN
measuredWidthproperty 
measuredWidth:Number  [read-write]

Returns the measured width after the control has been measured. Note this value will return NaN if the control is explicitly sized by setting the explicitWidth property

Implementation
    public function get measuredWidth():Number
    public function set measuredWidth(value:Number):void
_mouseActionsDisabledproperty 
protected var _mouseActionsDisabled:Boolean = false
mouseActionsDisabledproperty 
mouseActionsDisabled:Boolean  [read-only]Implementation
    public function get mouseActionsDisabled():Boolean
needsMeasurementproperty 
public var needsMeasurement:Boolean = true

Only setting percent width/heights changes the needsMeasurement flag which makes its parent container call measure on it. If width and height are set directly, measurement is never called (although size invalidation still does if size has changed)

_parentContainerproperty 
protected var _parentContainer:UIControl
parentContainerproperty 
parentContainer:UIControl  [read-write]Implementation
    public function get parentContainer():UIControl
    public function set parentContainer(value:UIControl):void
_percentHeightproperty 
protected var _percentHeight:Number
percentHeightproperty 
percentHeight:Number  [read-write]Implementation
    public function get percentHeight():Number
    public function set percentHeight(value:Number):void
_percentUnusedHeightproperty 
protected var _percentUnusedHeight:Number
percentUnusedHeightproperty 
percentUnusedHeight:Number  [read-write]

Set/get the percent height. If the value is different from the earlier, it sets the measurement flag and calls invalidateSize

Implementation
    public function get percentUnusedHeight():Number
    public function set percentUnusedHeight(value:Number):void
_percentUnusedWidthproperty 
protected var _percentUnusedWidth:Number
percentUnusedWidthproperty 
percentUnusedWidth:Number  [read-write]

Set/get the percent width. If the value is different from the earlier, it sets the measurement flag and calls invalidateSize

Implementation
    public function get percentUnusedWidth():Number
    public function set percentUnusedWidth(value:Number):void
_percentWidthproperty 
protected var _percentWidth:Number
percentWidthproperty 
percentWidth:Number  [read-write]Implementation
    public function get percentWidth():Number
    public function set percentWidth(value:Number):void
sizeInvalidatedproperty 
public var sizeInvalidated:Boolean = false

The flag to mark that the control's size has been invalidated. This means the control is now waiting for a validateSize call.

usesMeasurementStrategyproperty 
usesMeasurementStrategy:Boolean  [read-only]

This property defines whether measure() will be called during validateSize() or not.

Implementation
    public function get usesMeasurementStrategy():Boolean
visibleproperty 
visible:Boolean  [write-only]

Implementation
    public function set visible(value:Boolean):void
widthproperty 
width:Number  [read-write]

Set/get the width of the control. If the width is set to a different value from the one the control is already at, it triggers the size invalidation cycle

Implementation
    public function get width():Number
    public function set width(value:Number):void
Constructor detail
MeasurableControl()constructor
public function MeasurableControl()
Method detail
calculateMeasuredHeight()method
protected function calculateMeasuredHeight():void

Calculates the measuredHeight property.

calculateMeasuredWidth()method 
protected function calculateMeasuredWidth():void

Calculates the measuredWidth property.

cancelMouseEvents()method 
public function cancelMouseEvents():void
checkDisplayListValidation()method 
public function checkDisplayListValidation():void

Calls the queueValidateDisplayList if measure causes _dimensionsChanged to change to true. UIControl overrides this with a call to doChildBasedValidation which then goes and checks if the size of the children affects the size of the control.

createChildren()method 
protected function createChildren():void

This is where the new children should be created and then added to the displaylist. Similar to Flex's createChildren() method.

disableEvent()method 
protected function disableEvent(event:Event):voidParameters
event:Event
dispatchUpdateComplete()method 
protected function dispatchUpdateComplete():void

Dispatches the UpdateComplete event

doOnAdded()method 
public function doOnAdded():void

[Temp] This function is called automatically by a parent UIControl if this is created as a child of a UIControl. Else you have to call this function for now.

doQueuedValidateSize()method 
protected function doQueuedValidateSize(event:Event):void

doQueueValidateSize is executed by the top level UIControl.

Parameters
event:Event
enableMouseEvents()method 
public function enableMouseEvents():void
getExplicitOrMeasuredHeight()method 
public function getExplicitOrMeasuredHeight():Number

Returns the explicitly defined height or the measured height computed by the measure function.

Returns
Number
getExplicitOrMeasuredWidth()method 
public function getExplicitOrMeasuredWidth():Number

Returns the explicitly defined width or the measured number computed by the measure function.

Returns
Number
initialize()method 
public function initialize():void

This happens only once when a child is first added to any parent. Subsequent removeChild and addChild actions do not trigger this function but rather directly call validateSize.

invalidateDisplayList()method 
protected function invalidateDisplayList():void
invalidateSize()method 
public function invalidateSize(event:PyroEvent = null):void

Marks itself dirty and waits till either the container to validateSize or validates itself at the next enterframe if it has no parent container. This method is overridden by UIControl. The code here will only be useful for a Spacer type of component.

Parameters
event:PyroEvent (default = null)
isMouseOver()method 
public function isMouseOver(event:MouseEvent):Boolean

Utility function to check if a mouseEvent happened while the mouse was over the displayObject

Parameters
event:MouseEvent

Returns
Boolean
measure()method 
public function measure():void

Measure is called during the validateSize if the needsmeasurement flag is set. At this point, new measured width/heights are calculated. If these values are different from the values previously calculated, the resizeHandler is queued for the next enterframe

onAddedToParent()method 
protected function onAddedToParent(event:Event):void

The event listener executed when this component has been added to the parent.

Parameters
event:Event
queueValidateDisplayList()method 
public function queueValidateDisplayList(event:PyroEvent = null):void

This function is called if the framework determines that dimensions of the control have changed. This determination is made during the validateSize() function. If this control is the top level OpenPyro control, it will validate the displaylist in the next enter frame, otherwise it just dispatches the size changed event and waits till the validateDisplaylist is called.

Parameters
event:PyroEvent (default = null)
resizeHandler()method 
public function resizeHandler():void
updateDisplayList()method 
public function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void

The updateDisplayList is triggered everytime the framework determines that some event has taken place that needs the UI to be refreshed.

Parameters
unscaledWidth:Number — The computed width of the control
 
unscaledHeight:Number — The computed height of the control
validateDisplayList()method 
public function validateDisplayList(event:Event = null):void

validateDisplayList is called as a response to invalidateDisplayList.

Parameters
event:Event (default = null)
validateSize()method 
public function validateSize():void

The validateSize function is called in response to a component declaring its size invalid (usually by calling invalidateSize()). The job of this method is to compute the final width and height (whether by calling measure if an explicit w/h is not declared or not if an explicit w & h is declared)

See also

invalidateSize()
measure()
usesMeasurementStrategy
Event detail
initializeevent 
Event object type: org.openPyro.events.PyroEvent

preInitializeevent  
Event object type: org.openPyro.events.PyroEvent

propertyChangeevent  
Event object type: org.openPyro.events.PyroEvent

resizeevent  
Event object type: flash.events.Event

sizeChangedevent  
Event object type: org.openPyro.events.PyroEvent

sizeInvalidatedevent  
Event object type: org.openPyro.events.PyroEvent

sizeValidatedevent  
Event object type: org.openPyro.events.PyroEvent

updateCompleteevent  
Event object type: org.openPyro.events.PyroEvent