Copy link to clipboard
Copied
Hi
i've inserted a linkElement with a code such as this:
var edit:IEditManager = textFlow.interactionManager as IEditManager;
edit.selectRange(from,to);
edit.applyLink(url,'_blank');
textFlow.flowComposer.updateAllControllers();
and up to here all ok!
Now I must remove this linkElement, but I have not found functions to do this.
any help is welcome.
thank in advance ![]()
JeanPaul
For 2), I think it should be a loop in case that the structure is complex sometimes. 'Ancestor' is not just 'parent'.
3)
var link:LinkElement;
var children:Array = link.mxmlChildren.deepCopy();
var parentOfLink:FlowGroupElement = link.parent as FlowGroupElement;
var indexOfLink:int = parentOfLink.getChildIndex(link);
parentOfLink.replaceChildren(indexOfLink, indexOfLink + 1, children);
Copy link to clipboard
Copied
Yes, there is no one-line API to convert link back to plain text.
I believe there are many ways, one of which is as follows.
1)get the leaf element according to 'from' of selection
2)get the link element based on the leaf element returned in step 1 (detect leaf's ancestors, if it's a link, it must be the target link)
3)replace link element with all children elements of the link (the array of all children elements can be the third paramter of function link.parent.replaceChildren())
4)textflow.flowComposer.updateAllControllers()
Copy link to clipboard
Copied
Hi Jin-Huang
after the applyLink statament, the textFlow markup is similar to this:
<p><span>text before link</span><a href="http://www.link.com" target="_blank"><span>text of link</span></a><span>text after link</span></p>
a way to remove the link can be to act on the markup and than import it in textFlow, but I prefer your solution!
ok for first step, it point to span element that contains text of link, I think that to find the link can be used:
var lnk:LinkElement = span.parent as LinkElement;
but for the third step i don't know the statement.
can make me an example?
Copy link to clipboard
Copied
For 2), I think it should be a loop in case that the structure is complex sometimes. 'Ancestor' is not just 'parent'.
3)
var link:LinkElement;
var children:Array = link.mxmlChildren.deepCopy();
var parentOfLink:FlowGroupElement = link.parent as FlowGroupElement;
var indexOfLink:int = parentOfLink.getChildIndex(link);
parentOfLink.replaceChildren(indexOfLink, indexOfLink + 1, children);
Copy link to clipboard
Copied
No problem for the step 2, before performing var lnk:LinkElement = span.parent as LinkElement; I'm sure to be on the text connected to the link.
link.mxmlChildren.deepCopy(); give Error #1006: deepCopy is not a function.
I must replace with link.mxmlChildren.concat(); and then all work correctly
thank for all ![]()
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more