Skip to main content
Known Participant
January 25, 2011
Answered

editManager.splitParagraph(); inherits previous paragraph format

  • January 25, 2011
  • 2 replies
  • 1964 views

So here is a function that I'm using in a screenwriting application that is suppose to drop down a line, center it and cause the next line to be all caps.  However, the new paragraph inherits the previous paragraph's format.  Am I doing this right?  Is there a better way?  How can I cause a new paragraph to be inserted here with the new format?

public function character():void {

var cf:TextLayoutFormat = new TextLayoutFormat();

editManager.splitParagraph();

cf.paragraphSpaceBefore="10";

cf.textAlign = "center";

cf.typographicCase="uppercase";

IEditManager(textFlow.interactionManager).applyParagraphFormat(cf);

textFlow.interactionManager.setFocus();

}

thanks,

This topic has been closed for replies.
Correct answer rdermer

What you have here doesn't quite work because it only adds new formats.  In this case you want to use the clearFormatOperation to clear the ones that were copied first.  Before applyParagraphFormat call:

IEditManager(textFlow.interactionManager).clearFormat(null,TextLayoutFormat.defaultFormat,null);

In TLF 2.0 splitParagraph returns the newly created ParagraphElement.  You can then use clearFormatOnElement followed by applyFormatToElement to adjust clear any cloned styles from the previous paragraph and apply your desired styles.

In both cases wrap the splitParagraph, and the clear and apply formats up in a call to beginCompositeOperation/endCompositeOperation and it will be packaged up in a single undoable operation.

The setFocus call shouldn't be necessary.

Hope that helps,

Richard

2 replies

ddfletchAuthor
Known Participant
January 25, 2011

I've got most of the inherit issues solved but the typographicCase="uppercase"; for some reason will always stay uppercase, even when I've split the paragraph and changed the case to typographicCase="default";

rdermerCorrect answer
Adobe Employee
January 25, 2011

What you have here doesn't quite work because it only adds new formats.  In this case you want to use the clearFormatOperation to clear the ones that were copied first.  Before applyParagraphFormat call:

IEditManager(textFlow.interactionManager).clearFormat(null,TextLayoutFormat.defaultFormat,null);

In TLF 2.0 splitParagraph returns the newly created ParagraphElement.  You can then use clearFormatOnElement followed by applyFormatToElement to adjust clear any cloned styles from the previous paragraph and apply your desired styles.

In both cases wrap the splitParagraph, and the clear and apply formats up in a call to beginCompositeOperation/endCompositeOperation and it will be packaged up in a single undoable operation.

The setFocus call shouldn't be necessary.

Hope that helps,

Richard

ddfletchAuthor
Known Participant
January 25, 2011

I can't figure out why but your line of code

IEditManager(textFlow.interactionManager).clearFormat(null,TextLayoutFormat.defaultFormat,null);

is throwing an error.

1061: Call to a possibly undefined method clearFormat through a reference with static type flashx.textLayout.edit:IEditManager.

Adobe Employee
January 25, 2011

I don't either - that's been around since TLF 1.0.

Try this:

var em: IEditManager = textFlow.interactionManager as IEditManager;

if (!em)

     trace("not an edit manager");

em.clearFormat(null,TextLayoutF ormat.defaultFormat,null);

Does it compile?

Richard