Skip to main content
AdrianParr
Known Participant
January 6, 2010
Answered

CHANGE Event in TLF?

  • January 6, 2010
  • 2 replies
  • 1091 views

Is there an event that gets fired when the user types in to an editable TLF field?

For example, using an regular old TextField you could use ...

var tf:TextField = new TextField();
tf.border = true;
tf.width = 100;
tf.height = 20;
tf.type = TextFieldType.INPUT;
tf.border = true;
tf.multiline = false;
addChild(tf);

tf.addEventListener(Event.CHANGE, onTf_CHANGE);

function onTf_CHANGE(event:Event) :void {
    trace("onTf_CHANGE()");
}

How would I do this with TextFlow instance?

I've had a play with UpdateCompleteEvent.UPDATE_COMPLETE but that doesn't seem to be what I am looking for.

Thanks in advance.

Adrian

This topic has been closed for replies.
Correct answer robin_briggs

If you are using a Flex spark component, I believe there is a changing and a changed event you can listen for on the component. If you are using TLF directly, there is a FlowOperationEvent that is sent on the TextFlow - a flowOperationBegin is sent right before the edit is made, and a flowOperationEnd afterwards, and a flowOperationComplete when all updates are done.The operation can be canceled from the begin handler by calling preventDefault() on the event, or the handler can replace the operation or mutate it.

2 replies

AdrianParr
Known Participant
January 7, 2010

import flashx.textLayout.events.*;

FlowOperationEvent.FLOW_OPERATION_BEGIN

FlowOperationEvent.FLOW_OPERATION_END

FlowOperationEvent.FLOW_OPERATION_COMPLETE

robin_briggsCorrect answer
Adobe Employee
January 7, 2010

If you are using a Flex spark component, I believe there is a changing and a changed event you can listen for on the component. If you are using TLF directly, there is a FlowOperationEvent that is sent on the TextFlow - a flowOperationBegin is sent right before the edit is made, and a flowOperationEnd afterwards, and a flowOperationComplete when all updates are done.The operation can be canceled from the begin handler by calling preventDefault() on the event, or the handler can replace the operation or mutate it.

AdrianParr
Known Participant
January 7, 2010

Hi Robin,

Thanks mate, you are a life saver!

Here is my test code that demonstrates what you suggested ...

import flashx.textLayout.container.*;
import flashx.textLayout.elements.*;
import flashx.textLayout.formats.*;
import flashx.textLayout.edit.*;
import flashx.textLayout.events.*;

var textFlow:TextFlow = new TextFlow();
textFlow.fontSize = 30;

var p:ParagraphElement = new ParagraphElement();
textFlow.addChild(p);

var span:SpanElement = new SpanElement();
span.text = "Type here ...";
p.addChild(span);

var em:EditManager = new EditManager();
textFlow.interactionManager = em;

textFlow.flowComposer.addController(new ContainerController(this, 550, 400));
textFlow.flowComposer.updateAllControllers();

textFlow.addEventListener(FlowOperationEvent.FLOW_OPERATION_COMPLETE, onTextFlow_FLOW_OPERATION_COMPLETE);

function onTextFlow_FLOW_OPERATION_COMPLETE(event:FlowOperationEvent):void {
    trace(textFlow.getText());
}