Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8216849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:16:29+00:00 2026-06-07T12:16:29+00:00

My Flex/AS3 web application accesses a database and retrieves text containing \n for newline

  • 0

My Flex/AS3 web application accesses a database and retrieves text containing \n for newline character. Otherwise the text looks like normal text.

Is there a way to convert the \n into paragraph tags that I can insert into an spark TextFlow?

For example, my only experience with TLF is in writing mxml code such as follows:

<s:RichEditableText width="100%" height="100%"
                    textAlign="left" paddingTop="0"
                    paragraphSpaceAfter="0.3"
                    editable="false">
<s:textFlow>
  <s:TextFlow>
    <s:p fontWeight="bold" fontSize="15">My Title Text</s:p>
    <s:p fontSize="2"/>
    <s:p>{paragraph1_text}</s:p>
    <s:p>{paragraph2_text}</s:p>
    <s:p>{paragraph3_text}</s:p>
    <s:p fontSize="2"/>
  </s:TextFlow>
</s:textFlow>
</s:RichEditableText>

Suppose I retrieve a string from the database such as:

paragraph1_text = "This is some text.\nThis is some more text.\nThis is even more text."

Even though inserting this into the code above will recognize the new line character, it won’t recognize the paragraphSpaceAfter="0.3". My goal is to have the effect of:

<s:RichEditableText width="100%" height="100%"
                    textAlign="left" paddingTop="0"
                    paragraphSpaceAfter="0.3"
                    editable="false">
<s:textFlow>
  <s:TextFlow>
    <s:p fontWeight="bold" fontSize="15">My Title Text</s:p>
    <s:p fontSize="2"/>
    <s:p>This is some text.</s:p>
    <s:p>This is some more text.</s:p>
    <s:p>This is even more text.</s:p>
    <s:p>{paragraph2_text}</s:p>
    <s:p>{paragraph3_text}</s:p>
  <s:p fontSize="2"/>
</s:TextFlow>

Is there any way to achieve something like this programmatically (the database text could be anything)?

I tried changing paragraph1_text to:

paragraph1_text="<s:p>This is some text.</s:p><s:p>This is some more text.</s:p><s:p>This is even more text.</s:p>"

and then using this in the first code block above, but it simply printed out all of the <s:p> and </s:p> tags.

Any advice appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T12:16:30+00:00Added an answer on June 7, 2026 at 12:16 pm

    You can achieve this by using ActionScript. Let’s say you name your TextFlow like

    <s:TextFlow id="myFlow">
    

    Your ActionScript code block could look like:

    import flashx.textLayout.elements.*;
    
    public function insertParagraph( textFlow:TextFlow, text:String, locationIndex:uint ):void
    {
        var paragraphs:Vector.<ParagraphElement> = getParagraphElements( text );
        for ( var i:uint = 0; i < paragraphs.length; i++ )
        {
            textFlow.addChildAt( paragraphs[i], locationIndex + i );
        }
    }
    
    public function getParagraphElements( text:String ):Vector.<ParagraphElement>
    {
        var textParagraphs:Array = text.split("\n");
        var result:Vector.<ParagraphElement> = new Vector.<ParagraphElement>();
        for ( var i:uint = 0; i < textParagraphs.length; i++ )
        {
            var p:ParagraphElement = new ParagraphElement();
            var span:SpanElement = new SpanElement();
            span.text = textParagraphs[i];
            p.addChild(span);
            result.push(p);
        }
    
        return result;
    }
    

    In your case, since you want to add the paragraphs starting as the 3rd element, once the text is retrieved, you can call insertParagaph( myFlow, text, 2 );

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

My group is working on a Flex/AS3 scientific web application that is data intensive.
Newbie question. I'm developing a web application (I'm using Flex/AS3, but for the purposes
I'm warming up w/ AS3 robotlegs framework. I'm working on a FLEX 4/AIR Application
We are in the process of the optimization of a Flex AS3 Application. One
I have a web application developed in Adobe Flex 3 and Python 2.5 (deployed
So I've got an xml like this stored in a variable in Flex AS3
I would like to tak emy existing AS3 or Flex project and compile it
Porting a pure Flash/AS3 application to Flex 4.5 this code: <fx:Script> <![CDATA[ import mx.events.SliderEvent;
I'm new to Flex and am porting a pure Flash/AS3 application to Flex 4.5.
I'm a Flex newbie and am porting a pure Flash/AS3 application to Flex 4.5.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.