Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
Locked
0

Is it possible to add paragraphs with actionscript?

Engaged ,
Oct 27, 2009 Oct 27, 2009

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 ]

}

TOPICS
Text layout framework
631
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Oct 27, 2009 Oct 27, 2009

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);

     }

}

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2009 Oct 28, 2009

What's the "TextFlow" that I pass it? It's obviously not the RichText

object's ID, but I am confused.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Oct 28, 2009 Oct 28, 2009
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines