Packageimpression.utilities
Classpublic class TreeNode
InheritanceTreeNode Inheritance flash.display.Sprite

The TreeNode class represents a single node in a TreeView. Note that TreeNodes should only be created by a TreeView.



Public Properties
 PropertyDefined By
  attributeName : String
[read-only] The name of the attribute in the XML object that contains the text to display for the node.
TreeNode
  expanded : Boolean
[read-only] Indicates the expanded state of the node.
TreeNode
  hasChildren : Boolean
[read-only] Indicates whether the node has children.
TreeNode
  owner : TreeView
[read-only] The TreeView object that owns this TreeNode.
TreeNode
  selected : Boolean
[read-only] Indicates the selection state of the node.
TreeNode
  source : XML
[read-only] The XML object containing the data for this TreeNode.
TreeNode
  styleName : String
The named style associated with the node.
TreeNode
Public Methods
 MethodDefined By
  
clearStyle(style:String):void
Deletes a style property from the node.
TreeNode
  
getStyle(style:String):Object
Retrieves a style property for the node.
TreeNode
  
[static] Retrieves the default style map for the node.
TreeNode
  
redraw():void
Redraws the node.
TreeNode
  
setStyle(style:String, value:Object):void
Sets a style property for the node.
TreeNode
  
toString():String
[override] Returns the string representation of the specified object.
TreeNode
Events
 Event Summary Defined By
  Dispatched after the .redraw() method is invoked.TreeNode
  Dispatched when the node is resized.TreeNode
Styles
 Style Description Defined By
  
antiAliasType
Type: flash.text.AntiAliasType
Indicates the type of antialiasing that will be used by the text field. The default value is AntiAliasType.ADVANCED.
TreeNode
  
backgroundColor
Type: uint Format: Color
The background color of the text field when the node is not selected. The default value is 0xFFFFFF.
TreeNode
  
borderColor
Type: uint Format: Color
The border color of the text field when the node is not selected. The default value is 0x000000.
TreeNode
  
cacheAsBitmap
Type: Boolean
Indicates the value of the node's cacheAsBitmap property. The default value is true.

See also

flash.display.DisplayObject.cacheAsBitmap
TreeNode
  
doubleClickEnabled
Type: Boolean
Indicates whether double-clicking on the node is enabled. If this value is true, double-clicking on the node will toggle its expanded state. The default value is false.
TreeNode
  
embedFonts
Type: Boolean
Indicates whether embedded fonts should be used. The default value is false.
TreeNode
  
expandable
Type: Boolean
Indicates whether the node can be expanded/collapsed by double-clicking. If this value is false, the node can still be expanded or collapsed programatically. The default value is true.
TreeNode
  
filters
Type: Array
The filters to apply to the text when the node is not selected. The default value is null.
TreeNode
  
fontBold
Type: Boolean
The bold state of the font used for text when the node is not selected. The default value is false.
TreeNode
  
fontItalic
Type: Boolean
The italic state of the font used for text when the node is not selected. The default value is false.
TreeNode
  
fontName
Type: String
The font family name used for text when the node is not selected. The default value is "Arial".
TreeNode
  
fontSize
Type: Number
The size, in pixels, used for text when the node is not selected. The default value is 10.
TreeNode
  
fontUnderline
Type: Boolean
The underline state of the font used for text when the node is not selected. The default value is false.
TreeNode
  
height
Type: Number
The height of the node when it is not selected, in pixels. If this value is Number.NaN, it is ignored. The default value is Number.NaN.
TreeNode
  
htmlText
Type: Boolean
Indicates whether the text of the node should be treated as HTML or not. If you plan on using stylesheets, this property value should be set to true. The default value is false.
TreeNode
  
icon
Type: Object
Identifies the icon to use when the node is not selected.

This value can be a String or an Object. If the value is a String, the TreeNode will attempt to create a new instance of the class identified by the value. If the value is an Object, the TreeNode will attempt to use it as a display object.

The default value is "nodeIcon".
TreeNode
  
iconTextSpacing
Type: Number Format: Length
The spacing between the right edge of the icon and the left edge of the text field when the node is not selected, in pixels. The default value is 4.
TreeNode
  
nodeBackground
Type: flash.display.DisplayObject
A DisplayObject to use as the background for the node when the node is not selected.

Note that this object is always positioned at (0,0). The padding style values apply only to the icon and text.

The default value is null.
TreeNode
  
nodeBackgroundAutosize
Type: Boolean
Identifies how the nodeBackground display object, if present, should be resized.

If this style value is true, and the width or height styles are finite positive numbers, then the display object is resized to the valid style values, otherwise, the display object is resized to the calculated width and height of the node.

If this style value is false, the size of the display object is unchanged. In this case, the icon and text objects are vertically centered on the display object. The text object's width (including the right-side padding) will be adjusted to fit within the node background, expanding or truncating the text as appropriate.

The default value is true.
TreeNode
  
padding
Type: Number Format: Length
The padding between the outermost edges of the icon and text and the TreeNode when the node is not selected, in pixels. The default value is 2.
TreeNode
  
selectable
Type: Boolean
Indicates whether the node can be selected. The default value is true.
TreeNode
  
selectedBackgroundColor
Type: uint Format: Color
The background color of the text field when the node is selected. If this value is null, the backgroundColor style value is used. The default value is 0x0000C0.
TreeNode
  
selectedBorderColor
Type: uint Format: Color
The border color of the text field when the node is selected. The default value is 0x000000.
TreeNode
  
selectedFilters
Type: Array
The filters to apply to the text when the node is selected. The default value is null.
TreeNode
  
selectedFontBold
Type: Boolean
The bold state of the font used for text when the node is selected. If this value is null, the fontBold style value is used. The default value is null.
TreeNode
  
selectedFontItalic
Type: Boolean
The italic state of the font used for text when the node is selected. If this value is null, the fontItalic style value is used. The default value is null.
TreeNode
  
selectedFontName
Type: String
The font family name used for text when the node is selected. If this value is null, the fontName style value is used. The default value is null.
TreeNode
  
selectedFontSize
Type: Number
The size, in pixels, used for text when the node is selected. If this value is null, the fontSize style value is used. The default value is null.
TreeNode
  
selectedFontUnderline
Type: Boolean
The underline state of the font used for text when the node is selected. If this value is null, the fontUnderline style value is used. The default value is null.
TreeNode
  
selectedHeight
Type: Number
The height of the node when selected, in pixels. If this value is Number.NaN, it is ignored. The default value is Number.NaN.
TreeNode
  
selectedIcon
Type: Object
Identifies the icon to use when the node is selected. If this value is null, the icon style value is used.

This value can be a String or an Object. If the value is a String, the TreeNode will attempt to create a new instance of the class identified by the value. If the value is an Object, the TreeNode will attempt to use it as a display object.

The default value is null.
TreeNode
  
selectedIconTextSpacing
Type: Number Format: Length
The spacing between the right edge of the icon and the left edge of the text field when the node is selected, in pixels. If this value is null, the iconTextSpacing style value is used. The default value is null.
TreeNode
  
selectedNodeBackground
Type: flash.display.DisplayObject
A DisplayObject to use as the background for the node when the node is selected.

Note that this object is always positioned at (0,0). The padding style values apply only to the icon and text.

If this style value is null, the value of the nodeBackground style will be used instead.

The default value is null.
TreeNode
  
selectedNodeBackgroundAutosize
Type: Boolean
Identifies how the selectedNodeBackground display object, if present, should be resized.

If this style value is true, and the width or height styles are finite positive numbers, then the display object is resized to the valid style values, otherwise, the display object is resized to the calculated width and height of the node.

If this style value is false, the size of the display object is unchanged. In this case, the icon and text objects are vertically centered on the display object. The text object's width (including the right-side padding) will be adjusted to fit within the node background, expanding or truncating the text as appropriate.

If this style value is null, the value of the nodeBackgroundAutosize style will be used instead.

The default value is null.
TreeNode
  
selectedPadding
Type: Number Format: Length
The padding between the outermost edges of the icon and text and the TreeNode when the node is selected, in pixels. If this value is null, the padding style value is used. The default value is null.
TreeNode
  
selectedStyleSheet
Type: flash.text.StyleSheet
The style sheet to use for the text when the node is selected. If this value is null, the styleSheet style value is used. Note that the stylesheet, if present, is set after the other text-related styles. The default value is null.
TreeNode
  
selectedTextColor
Type: uint Format: Color
The text color when the node is selected. If this value is null, the textColor style value is used. The default value is 0xFFFFFF.
TreeNode
  
selectedTextHasBackground
Type: Boolean
Indicates whether the text field has a solid background when the node is selected. The default value is true.
TreeNode
  
selectedTextHasBorder
Type: Boolean
Indicates whether the text field has a border when the node is selected. The default value is false.
TreeNode
  
selectedUseIcon
Type: Boolean
Indicates whether the icon should be displayed when the node is selected. If this value is null, the useIcon style value is used. The default value is null.
TreeNode
  
selectedWidth
Type: Number
The width of the node when selected, in pixels. If this value is Number.NaN, it is ignored. The default value is Number.NaN.
TreeNode
  
styleSheet
Type: flash.text.StyleSheet
The style sheet to use for the text when the node is not selected. Note that the stylesheet, if present, is set after the other text-related styles. To use the stylesheet, the htmlText style property should be set to true. The default value is null.
TreeNode
  
textColor
Type: uint Format: Color
The text color when the node is not selected. The default value is 0x000000.
TreeNode
  
textHasBackground
Type: Boolean
Indicates whether the text field has a solid background when the node is not selected. The default value is false.
TreeNode
  
textHasBorder
Type: Boolean
Indicates whether the text field has a border when the node is not selected. The default value is false.
TreeNode
  
useIcon
Type: Boolean
Indicates whether the icon should be displayed when the node is not selected. The default value is true.
TreeNode
  
width
Type: Number
The width of the node when it is not selected, in pixels. If this value is Number.NaN, it is ignored. The default value is Number.NaN.
TreeNode
Property Detail
attributeNameproperty
attributeName:String  [read-only]

The name of the attribute in the XML object that contains the text to display for the node.


Implementation
    public function get attributeName():String
expandedproperty 
expanded:Boolean  [read-only]

Indicates the expanded state of the node.

The default value is false.


Implementation
    public function get expanded():Boolean
hasChildrenproperty 
hasChildren:Boolean  [read-only]

Indicates whether the node has children.


Implementation
    public function get hasChildren():Boolean
ownerproperty 
owner:TreeView  [read-only]

The TreeView object that owns this TreeNode.


Implementation
    public function get owner():TreeView
selectedproperty 
selected:Boolean  [read-only]

Indicates the selection state of the node.

The default value is false.


Implementation
    public function get selected():Boolean
sourceproperty 
source:XML  [read-only]

The XML object containing the data for this TreeNode.


Implementation
    public function get source():XML
styleNameproperty 
styleName:String

The named style associated with the node. This value should be a string that was previously added to the owning TreeView using the setNodeStyle.


Implementation
    public function get styleName():String
    public function set styleName(value:String):void

See also

Method Detail
clearStyle()method
public function clearStyle(style:String):void

Deletes a style property from the node.

Parameters

style:String — The name of the style property.

See also

getStyle()method 
public function getStyle(style:String):Object

Retrieves a style property for the node.

Note that this method will only return style values that have been explicitly set using setStyle().

Parameters

style:String — The name of the style property.

Returns
Object — Style value.

See also

getStyleDefinition()method 
public static function getStyleDefinition():Object

Retrieves the default style map for the node.

Note that values from the default style map are used only if no specific value for a style was set using the setStyle() method and no specific value for a style was set in the owning TreeView by a call to setNodeStyle() using the style name specified by the styleName property.

Returns
Object — Default styles object.

See also

redraw()method 
public function redraw():void

Redraws the node.

When looking up a style to use for drawing, the TreeNode determines the style value to use according to the following rules:

If the node is selected, and an explicit value is not available either from the node or the owning TreeView, then the TreeNode attempts to retrieve the alternate, non-selected style value before the default style value is used.

When all drawing is complete, the TreeNodeDrawEvent.AFTER_REDRAW event is dispatched. If the node's size has changed during drawing (or in code handling the AFTER_REDRAW event) the RESIZE event is dispatched.

See also

setStyle()method 
public function setStyle(style:String, value:Object):void

Sets a style property for the node.

Any style value set using this method will override the named style value from the owning TreeView, if one is set.

Parameters

style:String — The name of the style property.
 
value:Object — The value of the style.

See also

toString()method 
override public function toString():String

Returns the string representation of the specified object.

Returns
String — The string representation of the specified object.
Event Detail
afterRedraw Event
Event Object Type: impression.events.TreeNodeDrawEvent
TreeNodeDrawEvent.type property = TreeNodeDrawEvent.AFTER_REDRAW

Dispatched after the .redraw() method is invoked.

See also

resize Event  
Event Object Type: flash.events.Event
Event.type property = flash.events.Event.RESIZE

Dispatched when the node is resized.