Skip to main content
March 12, 2009
Answered

Copying a TextFlow element

  • March 12, 2009
  • 1 reply
  • 583 views
Ok apparently i don't fully know what i am doing, i am trying to copy a TextFlow object, so i can past it reformatted into another location.

what i am trying looks like the code attached with "this._textFlow" already being a working and highly formatted TextFlow, what i get when i try to remove children of this copy is an error like

"newElement still owned by another FlowGroupElement" ... so i don't think i am getting a unique copy, also i am unable to change the styles in this copy by traversing through the display hierarchy (seen in the other attached code). Though this dose work if i loop through the original TextFlow and re render it.

After this code not working, I know what i am doing is probably the wrong way about doing what i want to do, but i am not seeing any methods or new classes that will allow me to do what i am trying to do...has anybody done something like this?
This topic has been closed for replies.
Correct answer rdermer
A couple of comments.
1) no reason to copy the configuration. Just say new TextFlow(_textFlow.configuration)
2) Your addChild call adds a _textFlow (type TextFlow I assume) as a child of copyFlow. That's not permitted. A textFlow can't have a parent.
3) Why not just say copyFlow = _textFlow.deepCopy()?
4) This is changing - we didn't used to permit adding a FlowElement as a child of another FlowElement unless its parent is null. That's changing (did it change in 370?) so that addChild will remove it if its already parented.

Hope that helps
Richard

1 reply

rdermerCorrect answer
Adobe Employee
March 12, 2009
A couple of comments.
1) no reason to copy the configuration. Just say new TextFlow(_textFlow.configuration)
2) Your addChild call adds a _textFlow (type TextFlow I assume) as a child of copyFlow. That's not permitted. A textFlow can't have a parent.
3) Why not just say copyFlow = _textFlow.deepCopy()?
4) This is changing - we didn't used to permit adding a FlowElement as a child of another FlowElement unless its parent is null. That's changing (did it change in 370?) so that addChild will remove it if its already parented.

Hope that helps
Richard
March 16, 2009
ah yes,

var copyFlow:TextFlow = TextFlow(this._textFlow.deepCopy());

works very well, thank you, i guess i assumed the deepCopy method returned a generic FlowElement and could not be cast to a TextFlow object, but it can because it is a TextFlow essentially, your guidance is greatly appreciated.