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

Is it possible to add paragraphs with actionscript?

Engaged ,
Oct 27, 2009 Oct 27, 2009

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 ]

}

TOPICS
Text layout framework

Views

571

Translate

Translate

Report

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

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

     }

}

Votes

Translate

Translate

Report

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

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.

Votes

Translate

Translate

Report

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

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

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