flashx.textLayout.operations

# ApplyLinkOperation - AS3

Package | flashx.textLayout.operations
Class | public class ApplyLinkOperation
Inheritance | ApplyLinkOperation FlowTextOperation FlowOperation Object

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

The ApplyLinkOperation class encapsulates a link creation or modification operation.

View the examples

Related API Elements

flashx.textLayout.elements.LinkElement
flashx.textLayout.edit.EditManager
flashx.textLayout.events.FlowOperationEvent

Public Properties
Hide Inherited Public Properties
Show Inherited Public Properties

| Property | Defined By
--- | --- | ---
|  | absoluteEnd : int The absolute end point of the range of text to which this operation is applied. | FlowTextOperation
|  | absoluteStart : int The absolute start point of the range of text to which this operation is applied. | FlowTextOperation
|  | beginGeneration : uint [read-only] The text flow generation before the operation. | FlowOperation
|  | constructor : Object A reference to the class object or constructor function for a given object instance. | Object
|  | endGeneration : uint [read-only] The text flow generation after the operation. | FlowOperation
|  | extendToLinkBoundary : Boolean Whether to extend the selection to include the entire text of any existing links overlapped by the selection, and then apply the change. | ApplyLinkOperation
|  | href : String The URI to be associated with the link. | ApplyLinkOperation
|  | newLinkElement : LinkElement [read-only] The LinkElement that was created by doOperation. | ApplyLinkOperation
|  | originalSelectionState : SelectionState The selection state at the start of the operation. | FlowTextOperation
|  | target : String The target of the link. | ApplyLinkOperation
|  | textFlow : flashx.textLayout.elements:TextFlow The TextFlow object to which this operation is applied. | FlowOperation
|  | userData : * Arbitrary data associated with an element. | FlowOperation

Public Methods
Hide Inherited Public Methods
Show Inherited Public Methods

| Method | Defined By
--- | --- | ---
|  | ApplyLinkOperation(operationState:SelectionState, href:String, target:String, extendToLinkBoundary:Boolean) Creates an ApplyLinkOperation object. | ApplyLinkOperation
|  | canUndo():Boolean Test if this operation be placed on the undo stack. | FlowOperation
|  | doOperation():Boolean Executes the operation. | FlowOperation
|  | hasOwnProperty(name:String):Boolean Indicates whether an object has a specified property defined. | Object
|  | isPrototypeOf(theClass:Object):Boolean Indicates whether an instance of the Object class is in the prototype chain of the object specified as the parameter. | Object
|  | propertyIsEnumerable(name:String):Boolean Indicates whether the specified property exists and is enumerable. | Object
|  | redo():SelectionState [override] Re-executes the operation. | FlowTextOperation
|  | setPropertyIsEnumerable(name:String, isEnum:Boolean = true):void Sets the availability of a dynamic property for loop operations. | Object
|  | toLocaleString():String Returns the string representation of this object, formatted according to locale-specific conventions. | Object
|  | toString():String Returns the string representation of the specified object. | Object
|  | undo():SelectionState Reverses the operation. | FlowOperation
|  | valueOf():Object Returns the primitive value of the specified object. | Object

Property Detail

### extendToLinkBoundary

property

`extendToLinkBoundary:Boolean`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

Whether to extend the selection to include the entire text of any existing links overlapped by the selection, and then apply the change.

Implementation
`public function get extendToLinkBoundary():Boolean`
`public function set extendToLinkBoundary(value:Boolean):void`

### href

property

`href:String`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

The URI to be associated with the link. If href is an empty string, the URI of links in the selection are removed.

Implementation
`public function get href():String`
`public function set href(value:String):void`

### newLinkElement

property

`newLinkElement:LinkElement` [read-only]

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 2.0

The LinkElement that was created by doOperation.

Implementation
`public function get newLinkElement():LinkElement`

### target

property

`target:String`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

The target of the link.

Implementation
`public function get target():String`
`public function set target(value:String):void`
Constructor Detail

### ApplyLinkOperation

()
Constructor

`public function ApplyLinkOperation(operationState:SelectionState, href:String, target:String, extendToLinkBoundary:Boolean)`

Language Version: | ActionScript 3.0

Runtime Versions: | Flash Player 10, AIR 1.5

Creates an ApplyLinkOperation object.

Parameters

| `operationState:SelectionState` — The text range to which the operation is applied.
| `href:String` — The URI to be associated with the link. If href is an empty string, the URI of links in the selection are removed.
| `target:String` — The target of the link.
| `extendToLinkBoundary:Boolean` — Whether to extend the selection to include the entire text of any existing links overlapped by the selection, and then apply the change.

Examples How to use this example
ApplyLinkOperation_example.as

This code snippet shows a use of the `ApplyLinkOperation` class. Before an operation of this type is executed, the link being applied to this TextFlow is verified. If the link is invalid, the event is cancelled and the link is not applied.

Copy

    package flashx.textLayout.operations.examples
    {
        import flashx.textLayout.elements.TextFlow;
        import flashx.textLayout.events.FlowOperationEvent;
        import flashx.textLayout.operations.FlowOperation;
        import flashx.textLayout.operations.ApplyLinkOperation;

        public class ApplyLinkOperation_example
        {
            public function attach(textFlow:TextFlow):void
            {
                textFlow.addEventListener(FlowOperationEvent.FLOW_OPERATION_BEGIN, opBeginHandler);
            }

            public function opBeginHandler(evt:FlowOperationEvent):void {
                var flowOp:FlowOperation = evt.operation;
                if(flowOp is ApplyLinkOperation && evt.cancelable) {
                    //if link is invalid, cancel link operation
                    if(!linkValid(flowOp.textFlow)) {
                        evt.preventDefault();
                    }
                }
            }
            private function linkValid(tf:TextFlow):Boolean {
                //code to check inserted link text in this TextFlow for validity
                return false;
            }
        }
    }

© 2015 Adobe Systems Incorporated. All rights reserved.
Mon Apr 10 2017, 12:28 PM -07:00