Stroke

Sprite
Stroke

Defines a stroke object consisting of curves, line segments and primitive graphics objects.

Summary
StrokeDefines a stroke object consisting of curves, line segments and primitive graphics objects.
Static properties
strokeNameDisplay object name of a stroke.
enableChangeCallbacksSet to false to disable callback and render calls.
Stroke class types
classSpriteClass type sprite, it is a branch node with children
classShapeClass type shape, it is a leat node with no children
classPathClass type path, it is a leaf with a motion or advanced value path
Stroke point names
pointNameDisplay object name of a stroke point sprite.
controlNameDisplay object name of a control point sprite.
cornerNameDisplay object name of a corner point sprite.
Public properties
classTypeStroke class type, see Stroke class types
itemsArray of StrokeItem objects
shapeDisplay object used as render target to display the stroke
filterStroke bitmap filter effects
isMaskSet to true if the stroke acts as a mask for its parent
parentNameName of the stroke’s parent in the scene graph
positionOffset position in parent
coordinateSystemLocal reference coordinate system
viewRectangleZoomed view rectangle
strokeRotationRotation of the stroke relative to parent
selectedIndexIndex of currently selected point in the stroke
Selection state
selectPointPoint selection
selectSegmentSegment selection
selectShapeShape selection
Private properties
pointsSprite with control point children
indicatorSelection indicator sprite
isHidingControlViewSet to true if the control view is hidden
hiddenPointsStateStored state for view of control points when hidden
hiddenIndicatorStateStored state for view of selection indicator when hidden
selectionChangeCallbackCallback invoked on selection index change
Construction/destruction
StrokeCreate a stroke object for a graphics shape or path.
setSelectionChangeCallbackChange the callback invoked when the selectedIndex in the stroke is changed.
disposeDispose of all resources used or referenced in the instance.
Property methods
shapeNameChange the name of the stroke asset.
shapeNameReturns the name of the stroke asset.
showPointsChange whether control points are shown (true) or not.
showPointsReturns true if control points are shown, false if not.
showIndicatorChange whether the selection indicator is shown (true) or not.
showIndicatorReturns true if the selection indicator is shown, false if not.
Control view
hideControlViewStore the control view state and hide the control points and indicator.
restoreControlViewRestore the control points and indicator to their state before a call to hideControlView.
Point sprites
createPointsReturns a new point sprite with buttonMode set.
removePointsRemoves the points sprite from the display list and deletes it.
Scaling
scaleScale all items in the stroke.
Render methods
renderRenders the stroke onto the shape display object.
renderToRenders the stroke onto the target display object.
renderActionRenders an item’s graphics action primitive on the render target.
Selection indicator
updateIndicatorChange position of the indicator to the selectedIndex stroke point position.
createIndicatorcreateIndicator code generated by µShape.
Item list methods
updateSelectedIndexChange the selectedIndex in the items array of StrokeItems.
newItemAppends a StrokeItem object to the end of the items array of StrokeItems.
newObjectAppends a graphics primitive object at the end of the items array of StrokeItems.
newDefaultPointAdds a new default segment start point to the items array of StrokeItems witha positionat origo.
newPointAdds a new segment start point to the items array of StrokeItems.
insertPointInserts a line or curve StrokeItem segment after the currently selected item.
appendPointAppends a line or curve StrokeItem segment at the end of the items array of StrokeItems.
deletePointDelete the StrokeItem at the given index.
Selection properties
beginSelectionIndexReturns the index of the first StrokeItem in the selection range determined by the current selectedIndex and the state of the selectPoint, selectSegment and selectShape variables.
endSelectionIndexReturns the index of the last StrokeItem in the selection range determined by the current selectedIndex and the state of the selectPoint, selectSegment and selectShape variables.
Query methods
indexOfStrokePointFinds the index of the StrokeItem that the stroke point sprite exists on.
indexOfControlPointFinds the index of the StrokeItem that the control point sprite exists on.
indexOfCornerPointFinds the index of the StrokeItem that the corner point sprite exists on.
hasGradientsReturns true if any StrokeItem objects in the Stroke uses a gradient fill, false otherwise.
Code generation
generateCodeGenerates script code for methods creating a stroke sprite, shape or a path.

Static properties

strokeName

public static const strokeName: String

Display object name of a stroke.

enableChangeCallbacks

public static var enableChangeCallbacks: Boolean

Set to false to disable callback and render calls.  For use by reverse engineering and SVG import.

Stroke class types

classSprite

public static const classSprite: String

Class type sprite, it is a branch node with children

classShape

public static const classShape: String

Class type shape, it is a leat node with no children

classPath

public static const classPath: String

Class type path, it is a leaf with a motion or advanced value path

Stroke point names

pointName

public static const pointName: String

Display object name of a stroke point sprite.

controlName

public static const controlName: String

Display object name of a control point sprite.

cornerName

public static const cornerName: String

Display object name of a corner point sprite.

Public properties

classType

public var classType: String

Stroke class type, see Stroke class types

items

public var items: Array

Array of StrokeItem objects

shape

public var shape: Shape

Display object used as render target to display the stroke

filter

public var filter: StrokeFilter

Stroke bitmap filter effects

isMask

public var isMask: Boolean

Set to true if the stroke acts as a mask for its parent

parentName

public var parentName: String

Name of the stroke’s parent in the scene graph

position

public var position: Point

Offset position in parent

coordinateSystem

public var coordinateSystem: Rectangle

Local reference coordinate system

viewRectangle

public var viewRectangle: Rectangle

Zoomed view rectangle

strokeRotation

public var strokeRotation: Number

Rotation of the stroke relative to parent

selectedIndex

public var selectedIndex: int

Index of currently selected point in the stroke

Selection state

selectPoint

public var selectPoint: Boolean

Point selection

selectSegment

public var selectSegment: Boolean

Segment selection

selectShape

public var selectShape: Boolean

Shape selection

Private properties

points

private var points: Sprite

Sprite with control point children

indicator

private var indicator: Shape

Selection indicator sprite

isHidingControlView

private var isHidingControlView: Boolean

Set to true if the control view is hidden

hiddenPointsState

private var hiddenPointsState: Boolean

Stored state for view of control points when hidden

hiddenIndicatorState

private var hiddenIndicatorState: Boolean

Stored state for view of selection indicator when hidden

selectionChangeCallback

private var selectionChangeCallback: Function

Callback invoked on selection index change

Construction/destruction

Stroke

public function Stroke(strokeStyles: Array,  
throughPoints: Array,  
curvePoints: Array,  
onSelectionChangeCallback: Function = null,
isDefaultItem: Boolean = false)

Create a stroke object for a graphics shape or path.

Parameters

strokeStylesarray of StrokeStyle objects
throughPointsarray of stroke Point positions
curvePointsarray of control Point positions
onSelectionChangeCallbackcallback invoked on selection index change
isDefaultItemSet to true if it is a default, see StrokeItem.isDefaultItem (default false)

Callbacks

onSelectionChangeCallbackfunction strokeChangedSelectedStrokePoint(index:int):void

setSelectionChangeCallback

public function setSelectionChangeCallback(
   onSelectionChangeCallback: Function
):void

Change the callback invoked when the selectedIndex in the stroke is changed.

Parameters

onSelectionChangeCallbackcallback invoked on selection index change

Callbacks

onSelectionChangeCallbackfunction strokeChangedSelectedStrokePoint(index:int):void

dispose

public function dispose():void

Dispose of all resources used or referenced in the instance.

Property methods

shapeName

public function set shapeName(newName: String):void

Change the name of the stroke asset.

Parameters

newNamea new name for the asset in the stroke

shapeName

public function get shapeName():String

Returns the name of the stroke asset.

showPoints

public function set showPoints(state: Boolean):void

Change whether control points are shown (true) or not.

showPoints

public function get showPoints():Boolean

Returns true if control points are shown, false if not.

showIndicator

public function set showIndicator(state: Boolean):void

Change whether the selection indicator is shown (true) or not.

showIndicator

public function get showIndicator():Boolean

Returns true if the selection indicator is shown, false if not.

Control view

hideControlView

internal function hideControlView():void

Store the control view state and hide the control points and indicator.

restoreControlView

internal function restoreControlView():void

Restore the control points and indicator to their state before a call to hideControlView.

Point sprites

createPoints

private function createPoints():Sprite

Returns a new point sprite with buttonMode set.

removePoints

private function removePoints():void

Removes the points sprite from the display list and deletes it.

Scaling

scale

public function scale(xScale: Number,
yScale: Number):void

Scale all items in the stroke.

Parameters

xScaleHorizontal scaling factor
yScaleVertical scaling factor

Render methods

render

public function render():void

Renders the stroke onto the shape display object.

renderTo

public function renderTo(target: Shape):void

Renders the stroke onto the target display object.

Parameters

targetdisplay object where the stroke is rendered

renderAction

private function renderAction(target: Shape,
item: StrokeItem):void

Renders an item’s graphics action primitive on the render target.

Parameters

targetshape where the stroke is rendered
itemthe item to render on the target

Selection indicator

updateIndicator

private function updateIndicator():void

Change position of the indicator to the selectedIndex stroke point position.

createIndicator

private function createIndicator():Shape

createIndicator code generated by µShape.

Returns

a Shape object

Item list methods

updateSelectedIndex

public function updateSelectedIndex(index: int):void

Change the selectedIndex in the items array of StrokeItems.

Parameters

indexa new valid selected index

newItem

public function newItem(item: StrokeItem):void

Appends a StrokeItem object to the end of the items array of StrokeItems.  The selectionChangeCallback is triggered.

Parameters

itema StrokeItem object

newObject

public function newObject(type: String,  
sPoint: Point,  
ctPoint: Point,  
crPoint: Point = null):void

Appends a graphics primitive object at the end of the items array of StrokeItems.  The selectionChangeCallback is triggered.

Parameters

typetype of graphics primitive
sPointstroke point position
ctPointcontrol point position
crPointcorner point position (default null)

newDefaultPoint

public function newDefaultPoint():void

Adds a new default segment start point to the items array of StrokeItems witha positionat origo.

Parameters

sPointstroke point position

newPoint

public function newPoint(sPoint: Point):void

Adds a new segment start point to the items array of StrokeItems.  The selectionChangeCallback is triggered.

Parameters

sPointstroke point position

insertPoint

public function insertPoint(sPoint: Point,  
cPoint: Point = null):void

Inserts a line or curve StrokeItem segment after the currently selected item.  The selectionChangeCallback is triggered.

Parameters

sPointstroke point position
cPointcontrol point position (default null)

appendPoint

private function appendPoint(sPoint: Point,  
cPoint: Point = null):void

Appends a line or curve StrokeItem segment at the end of the items array of StrokeItems.  The selectionChangeCallback is triggered.

Parameters

sPointstroke point position
cPointcontrol point position (default null)

deletePoint

public function deletePoint(index: int):void

Delete the StrokeItem at the given index.  The selectionChangeCallback is triggered.

Parameters

indexvalid item index

Selection properties

beginSelectionIndex

public function get beginSelectionIndex():int

Returns the index of the first StrokeItem in the selection range determined by the current selectedIndex and the state of the selectPoint, selectSegment and selectShape variables.

endSelectionIndex

public function get endSelectionIndex():int

Returns the index of the last StrokeItem in the selection range determined by the current selectedIndex and the state of the selectPoint, selectSegment and selectShape variables.

Query methods

indexOfStrokePoint

public function indexOfStrokePoint(sprite: Sprite):int

Finds the index of the StrokeItem that the stroke point sprite exists on.

Parameters

spritea stroke point sprite

Returns

Index of the StrokeItem if found else -1

indexOfControlPoint

public function indexOfControlPoint(sprite: Sprite):int

Finds the index of the StrokeItem that the control point sprite exists on.

Parameters

spritea control point sprite

Returns

Index of the StrokeItem if found else -1

indexOfCornerPoint

public function indexOfCornerPoint(sprite: Sprite):int

Finds the index of the StrokeItem that the corner point sprite exists on.

Parameters

spritea corner point sprite

Returns

Index of the StrokeItem if found else -1

hasGradients

public function hasGradients():Boolean

Returns true if any StrokeItem objects in the Stroke uses a gradient fill, false otherwise.

Code generation

generateCode

public function generateCode(title: String,
indent: String,
codeStyle: Object):String

Generates script code for methods creating a stroke sprite, shape or a path.

Parameters

titleversion decorated identification of the generating application
indentstring with spaces to indent each line of code
codeStyledynamic object with properties describing the desired code style

Returns

a script snippet

public static const strokeName: String
Display object name of a stroke.
public static var enableChangeCallbacks: Boolean
Set to false to disable callback and render calls.
public static const classSprite: String
Class type sprite, it is a branch node with children
public static const classShape: String
Class type shape, it is a leat node with no children
public static const classPath: String
Class type path, it is a leaf with a motion or advanced value path
public static const pointName: String
Display object name of a stroke point sprite.
public static const controlName: String
Display object name of a control point sprite.
public static const cornerName: String
Display object name of a corner point sprite.
public var classType: String
Stroke class type, see Stroke class types
public var items: Array
Array of StrokeItem objects
Defines a stroke item structure, that is a curve or line segment point or an object such as a circle, ellipse or rectangle.
public var shape: Shape
Display object used as render target to display the stroke
public var filter: StrokeFilter
Stroke bitmap filter effects
public var isMask: Boolean
Set to true if the stroke acts as a mask for its parent
public var parentName: String
Name of the stroke’s parent in the scene graph
public var position: Point
Offset position in parent
public var coordinateSystem: Rectangle
Local reference coordinate system
public var viewRectangle: Rectangle
Zoomed view rectangle
public var strokeRotation: Number
Rotation of the stroke relative to parent
public var selectedIndex: int
Index of currently selected point in the stroke
public var selectPoint: Boolean
Point selection
public var selectSegment: Boolean
Segment selection
public var selectShape: Boolean
Shape selection
private var points: Sprite
Sprite with control point children
private var indicator: Shape
Selection indicator sprite
private var isHidingControlView: Boolean
Set to true if the control view is hidden
private var hiddenPointsState: Boolean
Stored state for view of control points when hidden
private var hiddenIndicatorState: Boolean
Stored state for view of selection indicator when hidden
private var selectionChangeCallback: Function
Callback invoked on selection index change
public function Stroke(strokeStyles: Array,  
throughPoints: Array,  
curvePoints: Array,  
onSelectionChangeCallback: Function = null,
isDefaultItem: Boolean = false)
Create a stroke object for a graphics shape or path.
public function setSelectionChangeCallback(
   onSelectionChangeCallback: Function
):void
Change the callback invoked when the selectedIndex in the stroke is changed.
public function dispose():void
Dispose of all resources used or referenced in the instance.
public function set shapeName(newName: String):void
Change the name of the stroke asset.
public function set showPoints(state: Boolean):void
Change whether control points are shown (true) or not.
public function set showIndicator(state: Boolean):void
Change whether the selection indicator is shown (true) or not.
internal function hideControlView():void
Store the control view state and hide the control points and indicator.
internal function restoreControlView():void
Restore the control points and indicator to their state before a call to hideControlView.
private function createPoints():Sprite
Returns a new point sprite with buttonMode set.
private function removePoints():void
Removes the points sprite from the display list and deletes it.
public function scale(xScale: Number,
yScale: Number):void
Scale all items in the stroke.
public function render():void
Renders the stroke onto the shape display object.
public function renderTo(target: Shape):void
Renders the stroke onto the target display object.
private function renderAction(target: Shape,
item: StrokeItem):void
Renders an item’s graphics action primitive on the render target.
private function updateIndicator():void
Change position of the indicator to the selectedIndex stroke point position.
private function createIndicator():Shape
createIndicator code generated by µShape.
public function updateSelectedIndex(index: int):void
Change the selectedIndex in the items array of StrokeItems.
public function newItem(item: StrokeItem):void
Appends a StrokeItem object to the end of the items array of StrokeItems.
public function newObject(type: String,  
sPoint: Point,  
ctPoint: Point,  
crPoint: Point = null):void
Appends a graphics primitive object at the end of the items array of StrokeItems.
public function newDefaultPoint():void
Adds a new default segment start point to the items array of StrokeItems witha positionat origo.
public function newPoint(sPoint: Point):void
Adds a new segment start point to the items array of StrokeItems.
public function insertPoint(sPoint: Point,  
cPoint: Point = null):void
Inserts a line or curve StrokeItem segment after the currently selected item.
private function appendPoint(sPoint: Point,  
cPoint: Point = null):void
Appends a line or curve StrokeItem segment at the end of the items array of StrokeItems.
public function deletePoint(index: int):void
Delete the StrokeItem at the given index.
public function get beginSelectionIndex():int
Returns the index of the first StrokeItem in the selection range determined by the current selectedIndex and the state of the selectPoint, selectSegment and selectShape variables.
public function get endSelectionIndex():int
Returns the index of the last StrokeItem in the selection range determined by the current selectedIndex and the state of the selectPoint, selectSegment and selectShape variables.
public function indexOfStrokePoint(sprite: Sprite):int
Finds the index of the StrokeItem that the stroke point sprite exists on.
public function indexOfControlPoint(sprite: Sprite):int
Finds the index of the StrokeItem that the control point sprite exists on.
public function indexOfCornerPoint(sprite: Sprite):int
Finds the index of the StrokeItem that the corner point sprite exists on.
public function hasGradients():Boolean
Returns true if any StrokeItem objects in the Stroke uses a gradient fill, false otherwise.
public function generateCode(title: String,
indent: String,
codeStyle: Object):String
Generates script code for methods creating a stroke sprite, shape or a path.
Defines a stroke line and fill style for a line segment, a curve or a graphics primitive object.
public var isDefaultItem: Boolean
State set to true when a default segment start item is created.
Close