Copy link to clipboard
Copied
If I have an object like
<s:RichText id="foo">
<s:content></s:content>
</s:RichText>
Can I manually add paragraphs to it with actionscript?
I want to manually create a new paragraph, assign a string to it, and then stash it in the RichText object. So I can use a loop to create as many paragraphs as I might need.
Such as
for each (s:String in myCollection) {
[ foo add a p element with s in it ]
}
Copy link to clipboard
Copied
How about something like this?
public function appendToFlow(textFlow:TextFlow, myCollection:Array):void
{
for each (s:String in myCollection)
{
var p:ParagraphElement = new ParagraphElement();
var span:SpanElement = new SpanElement();
span.text = s;
p.replaceChildren(0, 0, span);
textFlow.replaceChildren(textFlow.numChildren, textFlow.numChildren, p);
}
}
Copy link to clipboard
Copied
What's the "TextFlow" that I pass it? It's obviously not the RichText
object's ID, but I am confused.
Copy link to clipboard
Copied
I think I've got it:
var textFlow:TextFlow = new TextFlow(); for each ( var s:String in instructionsArray) { var p:ParagraphElement = new ParagraphElement(); var span:SpanElement = new SpanElement(); span.text = s; p.replaceChildren(0, 0, span); textFlow.replaceChildren(textFlow.numChildren, textFlow.numChildren, p); } instructionText.content = textFlow;
Where "instructionText" is a RichText object.
This is very, very cool, btw.