Truncate text after first line in TextFlow

I have a TextFlow object which is rendered in a Sprite with multiple lines.
For a compact display I now want to display only the first line, followed by 3 dots (...).
I didn't find a good approach so far.

There is some support for truncation.  It's limited to label use cases and requires using the TextLine factories.  There is no support for editable text with truncation.   Example below.
Hope that helps,
Richard
ADOBE SYSTEMS INCORPORATED
Copyright 2011 Adobe Systems Incorporated
All Rights Reserved.
NOTICE:  Adobe permits you to use, modify, and distribute this file
in accordance with the terms of the Adobe license agreement
accompanying it.  If you have received this file from a source
other than Adobe, then your use, modification, or distribution
of it requires the prior written permission of Adobe.
package
    import flash.display.DisplayObject;
    import flash.display.Sprite;
    import flash.display.StageAlign;
    import flash.display.StageScaleMode;
    import flash.geom.Rectangle;
    import flash.text.StyleSheet;
    import flash.utils.ByteArray;
    import flashx.textLayout.container.ContainerController;
    import flashx.textLayout.conversion.TextConverter;
    import flashx.textLayout.elements.TextFlow;
    import flashx.textLayout.formats.TextLayoutFormat;
    import flashx.textLayout.factory.StringTextLineFactory;
    import flashx.textLayout.factory.TextFlowTextLineFactory;
    import flashx.textLayout.factory.TruncationOptions;
    [SWF(width="500", height="500")]
    public class Truncation extends Sprite
        public function Truncation()
            stage.align = StageAlign.TOP_LEFT;
            stage.scaleMode = StageScaleMode.NO_SCALE;
            // sample of truncation with the StringFactory
            var stringFactory:StringTextLineFactory = new StringTextLineFactory();
            var stringSprite:Sprite = new Sprite();
            stringSprite.x = 25; stringSprite.y = 25; addChild(stringSprite);
            // this bounds has no maximum height
            stringFactory.compositionBounds = new Rectangle(0,0,200,NaN);
            stringFactory.text = "This is an extremely long and overly verbose string of text that I would like to see trunctated.";
            // truncate after two lines
            stringFactory.truncationOptions = new TruncationOptions(TruncationOptions.HORIZONTAL_ELLIPSIS,2);
            stringFactory.createTextLines(function (obj:DisplayObject):void { stringSprite.addChild(obj); });
            // sample of truncation with the TextFlowTextLineFactory
            var flowFactory:TextFlowTextLineFactory = new TextFlowTextLineFactory();
            var flowSprite:Sprite = new Sprite();
            flowSprite.x = 25; flowSprite.y = 75; addChild(flowSprite);
            // this bounds has no maximum height
            flowFactory.compositionBounds = new Rectangle(0,0,200,NaN);
            // truncate after three lines with a big red ellipsis
            flowFactory.truncationOptions = new TruncationOptions(TruncationOptions.HORIZONTAL_ELLIPSIS,3,TextLayoutFormat.createTextLayoutFormat({ fontSize:24, lineHeight:0, color:0xff0000 }));
            flowFactory.createTextLines(function (obj:DisplayObject):void { flowSprite.addChild(obj); },TextConverter.importToFlow(Data.markup, TextConverter.TEXT_LAYOUT_FORMAT));
class Data
    public static const markup:String = "<TextFlow xmlns='http://ns.adobe.com/textLayout/2008' fontSize='10' textIndent='15' paragraphSpaceAfter='15' paddingTop='4' paddingLeft='4'>" +
        "<p>The following excerpt is from Ethan Brand by Nathaniel Hawthorne.</p>" +
        "<p><span>There are many </span><span fontStyle='italic'>such</span><span> lime-kilns in that tract of country, for the purpose of burning the white marble which composes" +
        " a large part of the substance of the hills. Some of them, built years ago, and long deserted, with weeds growing in the vacant round of the interior, which is open to the sky," +
        " and grass and wild-flowers rooting themselves into the chinks of the stones, look already like relics of antiquity, and may yet be overspread with the lichens of centuries to come." +
        " Others, where the lime-burner still feeds his daily and nightlong fire, afford points of interest to the wanderer among the hills, who seats himself on a log of wood or a fragment " +
        "of marble, to hold a chat with the solitary man. It is a lonesome, and, when the character is inclined to thought, may be an intensely thoughtful occupation; as it proved in the case " +
        "of Ethan Brand, who had mused to such strange purpose, in days gone by, while the fire in this very kiln was burning.</span></p><p><span>The man who now watched the fire was of a " +
        "different order, and troubled himself with no thoughts save the very few that were requisite to his business. At frequent intervals, he flung back the clashing weight of the iron door, " +
        "and, turning his face from the insufferable glare, thrust in huge logs of oak, or stirred the immense brands with a long pole. Within the furnace were seen the curling and riotous flames, " +
        "and the burning marble, almost molten with the intensity of heat; while without, the reflection of the fire quivered on the dark intricacy of the surrounding forest, and showed in the " +
        "foreground a bright and ruddy little picture of the hut, the spring beside its door, the athletic and coal-begrimed figure of the lime-burner, and the half-frightened child, shrinking " +
        "into the protection of his father's shadow. And when again the iron door was closed, then reappeared the tender light of the half-full moon, which vainly strove to trace out the " +
        "indistinct shapes of the neighboring mountains; and, in the upper sky, there was a flitting congregation of clouds, still faintly tinged with the rosy sunset, though thus far down " +
        "into the valley the sunshine had vanished long and long ago.</span></p></TextFlow>";

Similar Messages

  • Overlap text after first  page

    I created an Oracle report using Reports 6i. The report is to generate a shipping label, which is about 6x4 inches. If I preview on the screen or create the output on a normal letter size paper on a printer (8.5x11 inches), they look just fine.
    Because this report is for a shipping label, I print this on a Zebra label printer, ONLY the first page looks ok. Starting from the second page, the text was overlapped from the previous page. For example, an customer order has 3 boxes. I need to print three shipping labels by specifying an order number and it generates 3 labels.
    Each label has the same type of info like weight. Say Box 1's label has Weight=12 pounds, Box 2's labels has Weight= 34 pounds. Box 3's label has Weight=56 pounds. The first label always looks fine. The second label's Weight=34 is printed, BUT THE WEIGHT FROM THE PREVIOUS LABEL WEIGHT=12 WAS ALSO PRINTED ON TOP OF THE SECOND LABEL. Because the text WEIGHT= is exactly located on both labels and has the same text, it looks fine. The second label's weight 34 has also 12 printed on top.
    1. Do I need to change the setting in the properties? Also by default, the size indicated in the header, main body section, and trailer layout properties are set to Width size of 8.5 inches andI Length of 11 inches. (This is the standard size of a letter paper.) However, I am printing the label size of 6x4 inches, which is the size of the report in the layout editor.
    2. Does it have something to do with the continuation of the previous page? As mentioned above, when I print the label for testing on a 8.5x11 letter size paper. It has no problem. I use the Margin editor to set the dimension to just smaller than 6x4 inches, which is the label size. All the text fields of the label are inside the margin. However, on the layout editor, I saw some solid lines horizontally and verticallly outside of the margin (6x4).
    Note: The label printer works fine when using an existing application to print the label (report). So the printer itself does not seem to cause the problem.

    The problem was caused by an old driver. Need to install the new driver and everything should work just fine. Hope I can save your time if you run into this problem!!!

  • Text after each line item in Smartforms.

    Hi ,
    I am developing a smartform for Packlist.
    i want to display a text like this::
    Item    Prodcode           description                   Qty  uom     Picked   Factor
                batchNo           batch qty   reel size        to ship              qty
    10         19501       material description            200       M         0          3
                Ramesh      200               482448
                Sagar        200               482448
    Special instructions : text**
    20         19502      material description     200   M         0          3
                Ramesh     200               482448
               Sagar         200               482448
    Special instructions : text**
    Item 10 has 2 batches . after those 2 batches i want to display the Special instructions text.
    like this i want to display for all Items.
    How to give condition for this.
    thankx.
    Vikki

    Hi,
    Check whether the type of  it_final is of table type created in SE11...
    If not...
    create a structure with the fields of it_final... and then
    create a table type with the structure .
    Now in your smartform... in form interface... refer the type of it_final as table type and workarea as structure name
    regards
    padma

  • Problem with searching text after first paragraph

    Has anyone had problems finding text in a clob (with the contains() function) that is beyond the first paragraph?
    Is there some simple setting I've missed, or am I doing something wrong?

    You are doing something wrong.

  • Crystal 2008: Text, Can Grow=true, Max Lines=0, truncated after 2 lines

    I have a fairly simple, grouped report with a handful of fields in each Detail section, one of which is a note/text field.  I put the text field on its own line and set Can Grow = true, max lines = 0 so that it will display what it needs to display.
    This happens to be a crystalreports.com report using data coming from Salesforce, and I can see in the source report that I have about 7 lines of text for one of my groups, but crystal is truncating it after two lines, and in the middle of a word.
    The word ('for') doesn't have any obvious special characters in it, so I'm guessing that there's some sort of character limit that I'm bumping up against.
    I have another record that is returning more than two lines, though; are there particular characters that could cause this?  I can scrub the data and/or put Salesforce Validation Rules in place to try and prevent them from getting in.
    Any suggestions would be appreciated.
    Duncan

    Please re-post if this is still an issue or purchase a case and have a dedicated support engineer work with you directly:
    http://store.businessobjects.com/store/bobjamer/DisplayProductByTypePage&parentCategoryID=&categoryID=11522300?resid=-Z5tUwoHAiwAAA8@NLgAAAAS&rests=1254701640551

  • First Line Truncated

    Today I noticed in the Bridge and Photoshop forum that my first line of a response does a carriage return about a quarter the way across the page.  The first few times I thought I inadvertently hit the enter key.  But after it happened each time I decided that was not the case.
    Has anyone else experienced this?
    It did not happen on this Forum.
    Damm, had to retype as it gave me an error message on posting.
    Tripple damm, this is the 3rd attempt,  "unexplained error has occured", but still logged in.  But did a copy before posting and then paste this time.

    Curt,
    Welcome to the "New & Improved" Adobe forum experience. There is a new feature, the automatic line break. When the editing screen thinks that you need a line break, it gives you one.
    Acutally, this is happening to many of us. The published "fix" is to, well fix it.
    To date, this normally is happening in the first 3 lines of text, but not always. Keep an eye on the screen, as you type and be ready with the Backspace key. Mine is getting worn out. Normally, by about the third line, you're OK, but I had one instance tonight, where there were maybe 5 and I was on about line six.
    I've noticed that when these happen, the justification icons on the Toolbar often flash, and move slightly. Right now, with no auto line breaks, I see that the justification tools are offset about 2 pixels, from the formatting icons above. I do not know what this means, and it's just observation.
    Along with this, the Block Quote function is about 1:3, and sometimes cannot be used, regardless of what the user tries.
    Also, the camera icon attachment of an image is dead for many. Lately, others have used it, and have no issues. Maybe this is a rolling "fix," and will one day get to Arizona? My "guess" is that this was fixed in San Jose, and progressed westward. That means that I will be the last, but if it does get fixed, I'll live with that.
    Keep the faith, and just keep an eye on the screen, as you type. Hope that there is a real fix coming down the pike.
    Good luck,
    Hunt
    PS - see ya' in the PS forum, if I can stay logged-in as the_wine_snob...

  • Text node not showing first line?

    I'm trying to figure out some unexpected behavior with the layout of Text. If I create an example program based on the API documentation
    http://java.sun.com/javafx/1.2/docs/api/javafx.scene.text/javafx.scene.text.Text.html
    Like so:
    Stage
        title: "Application title"
        width: 500
        height: 500
        scene: Scene
            content: [ Text {font: Font { size: 20 } content: "First row\nSecond row" }  ]
    }The resulting screen only shows "Second row", the first line is moved out of the screen above. I need to set y to 20 to show the first line.
    Is that normal?

    Right, Text nodes have an textOrigin, which is default set to the base line. That means that y=0 is just below the letters.
    But the behavior is unexpected when simply adding a Text node and nothing is visible.

  • Removing first line in text file... Memory and HD concern

    Hello all,
    I want to remove the first line of a text file. This is easy... One way
    to do it, is to find the first "end of line" caracter, strip the string
    and re-write the sting in file with the "strip to sreadsheet" VI.
    Since the file can be quite large (about 120000 lines), is this a good
    way to do it. Will it re-write all the line or just moving the "begin
    of file" pointer to the second line? If it re-write the whole file,
    this option is not very good since I could have to do this operation
    quite often. (I want the file to be a kind of circular buffer / backup).
    What do you think is the best way to do this?
    Thanks!
    Vincent

    I think you would have to read in all the data and write it to a new file, you could either keep the data in RAM or simply write to another file then delete the original, and then rename the temp one.  So obviously that is a lot of data and memory.
    My main question is are you trying to use a text file as a circular buffer?  If so can you tell us more about the data, ie is it strings of a constant length?  Does a user ever need to read the file or could we head binary?
    A solution would be to truly make the file a binary file, so you could actually seek through the file easier, and maybe make the first data chunk the location of the most recent write.  The obvious danger is then writing over existing data.  This solution is still risky because of the data writes.
    You may want to look at some of the other file formats like HWS which maintains a hierarchy of data for you so you can simply add and remove data from it.  However, a user will not be able to easily read it.

  • I am doing a cover for O.M.G. by usher and it requires 4 to 5 different vocal layers. My first "line" of vocals keeps disappearing even after i save it. So I have to redo everything on the top line. Any help?

    I am doing a cover for O.M.G. by usher and it requires 4 to 5 different vocal layers. My first "line" of vocals keeps disappearing even after i save it. So I have to redo everything on the top line. Any help?

    For what it's worth, you posted this in 2011, and here in 2014 I am still having this same issue. Over the last two days, I have had to unlock my apple account 8 times. I didn't get any new devices. I haven't initiated a password reset. I didn't forget my password. I set up two factor authentication and have been able to do the unlocking with the key and using a code sent to one of my devices. 
    That all works.
    It's this having to unlock my account every time I go to use any of my devices. And I have many: iMac, iPad, iPad2, iPad mini, iPhone 5s, iPod touch (daughter), and my old iPhone 4 being used as an ipod touch now.  They are all synced, and all was working just fine.
    I have initiated an incident with Apple (again) but I know they are just going to suggest I change my Apple ID. It's a simple one, and one that I am sure others think is theirs. I don't want to change it. I shouldn't have to. Apple should be able to tell me who is trying to use it, or at least from where.
    Thanks for listening,
    Melissa

  • Could not parse the file contents as a data set. There were too many variable names in the first line of the text file.

    Could not parse the file contents as a data set. There were too many variable names in the first line of the text file.

    What are the Variables settings, what is the text file’s content, …?

  • Hyperlink cut after the first line

    Hello,
    we use adobe acrobat pro with adobe pdf printer. when we print a word document with hyperlinks over several lines with the pdf printer and open it after printing then the hyperlink will show's in the pdf document but the hyperlink will cut after the first line...
    can anybody tell my how i can fix this problem?
    thank you
    regards
    christopher

    The links you see in Acrobat or Reader after you print to the Adobe PDF printer are just the best guesses of these packages when it sees something like a link. To get the links embedded you either have to do it in Acrobat directly or use the Convert button as Bernd mentioned.

  • When I print a selection of text the top half of the first line is cut off, i. e. isn't printed, OS X 10.7.2, Firefox 9.0.1.

    When I try to print selected text ("Print Selection Only"), the top half of the first line of the first page is chopped off. Then the last line is chopped in half (top half on the bottom of page 1, bottom half on top of page 2). This occurs on all subsequent pages.

    I have a very similar problem on the same versions of Firefox and OS X as the OP.
    For me, the cutoff problem occurs on the top and bottom of ALL pages intermittently, depending on the line spacing of the current selection (or so I assume).

  • Only about 2/3 of the column show. Also, paragraphs on sidebars, such as the Youtube subtitle sentences are cut so after the first line I only see the top of the second line.

    Only about 2/3 of the column show. Also, paragraphs on sidebars, such as the Youtube subtitle sentences are cut so after the first line I only see the top of the second line.

    If you have increased the minimum font size then try the default setting "none" as a high value can cause issues like you described.
    * Firefox > Preferences > Content : Fonts & Colors > Advanced > Minimum Font Size (none)
    * Firefox > Preferences > Content : Fonts & Colors > Advanced > [X] "Allow pages to choose their own fonts, instead of my selections above"
    Reset the page zoom on pages that cause problems: <b>View > Zoom > Reset</b> (Ctrl+0 (zero); Cmd+0 on Mac)
    * http://kb.mozillazine.org/Zoom_text_of_web_pages

  • File Sender adapter not reading the first line

    Hi,
    I have a scenario configured from file to jdbc adapter.
    However, I found a problem in my file sender adapter. My file adpater always not picking up the first line from my text even I have set the 'Document Offset' to 0.
    Any Ideas? Thanks.
    Regards,
    Pua

    Hi Latika Sethi,
    My complete input text file is as below, it contains only 2 testing records:-
    H1|DIZ1                          |A0016507    |10000020|09/2007
    H2|ABC0001
    D|P|0001|Gaji Pokok       |   1,000.09
    D|D|0002|Denda              |   1,000.00
    D|P|0003|Elaun               |   1,000.00
    H1|PUA1                        |A0016508    |10000021|09/2007
    H2|ABC0002
    D|P|0001|Gaji Pokok       |   2,744.09
    D|D|0002|Denda              |   2,000.00
    D|P|0003|Elaun               |   2,000.00
    After the message mapping, I found the pipeline existed in sxmb_moni as below:-
    <?xml version="1.0" encoding="utf-8"?>
    <ns:mt_rmp03B_filejdbc_sender xmlns:ns="urn:rmp03:pdrm:ips:jdbcjdbc">
    <PaySlip>
    ..<Header2>
    .... <IC>ABC0001</IC>
    .. </Header2>
    .. <Details>
    .... <Jenis>P</Jenis>
    .... <No>0001</No>
    .... <Deskripsi>Gaji Pokok</Deskripsi>
    .... <Jumlah>1,000.09</Jumlah>
    .. </Details>
    </PaySlip>
    <PaySlip>
    .. <Header1>
    .... <Nama>PUA1</Nama>
    .... <KWSP>A0016508</KWSP>
    .... <NoGaji>10000021</NoGaji>
    .... <Bulan>09/2007</Bulan>
    .. </Header1>
    .. <Header2>
    .... <IC>ABC0002</IC>
    .. </Header2>
    .. <Details>
    .... <Jenis>P</Jenis>
    .... <No>0001</No>
    .... <Deskripsi>Gaji Pokok</Deskripsi>
    .... <Jumlah>2,744.09</Jumlah>
    .. </Details>
    </Payslip>
    There are 2 payslips as for the top payslip node...Header1 tag is missing. It means that during the file sender step....the first line of my record which is :-
    "H1|DIZ1                          |A0016507    |10000020|09/2007"
    is not read into the xi pipeline. Basically this is the problem i faced.
    Has somebody facing the same problem before? Currently I have no choice but moved the First line of the text into Second line and left the first line of the text become null/ empty line. As such both records can be successfully read by the XI.
    However what I wondered is sometimes clients will do insert the records into the first line and this might made some data loss.
    Thanks...

  • IMac OS 10.9.4 software updates apparent cause of Corel Painter X3 crash: I have run Disk Utility - no probs there, reinstalled Painter X3 (after first uninstalling X3). What now?

    iMac 10.9.4 software updates last week is apparent cause of my Corel Painter X3 now crashing. I ran Disk Utility check - no probs there. I reinstalled Painter X3 (after first uninstalling X3), still no success. Online Mac support suggest I use MacCleaner - tried at online Mac store & was referred to 0800 tech support for guidance - still waiting for reply.   

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    For this step, the title of the Console window should be All Messages. If it isn't, select
              SYSTEM LOG QUERIES ▹ All Messages
    from the log list on the left. If you don't see that list, select
              View ▹ Show Log List
    from the menu bar at the top of the screen.
    In the top right corner of the Console window, there's a search box labeled Filter. Initially the words "String Matching" are shown in that box. Enter the name of the crashed application or process. For example, if iTunes crashed, you would enter "iTunes" (without the quotes.)
    Each message in the log begins with the date and time when it was entered. Select the messages from the time of the last crash, if any. Copy them to the Clipboard by pressing the key combination command-C. Paste into a reply to this message by pressing command-V.
    ☞ The log contains a vast amount of information, almost all of which is irrelevant to solving any particular problem. When posting a log extract, be selective. A few dozen lines are almost always more than enough.
    Please don't indiscriminately dump thousands of lines from the log into this discussion.
    Please don't post screenshots of log messages—post the text.
    ☞ Some private information, such as your name, may appear in the log. Anonymize before posting.
    Step 2
    In the Console window, select
              DIAGNOSTIC AND USAGE INFORMATION ▹ User Diagnostic Reports
    (not Diagnostic and Usage Messages) from the log list on the left. There is a disclosure triangle to the left of the list item. If the triangle is pointing to the right, click it so that it points down. You'll see a list of crash reports. The name of each report starts with the name of the process, and ends with ".crash". Select the most recent report related to the process in question. The contents of the report will appear on the right. Use copy and paste to post the entire contents—the text, not a screenshot.
    I know the report is long, maybe several hundred lines. Please post all of it anyway.
    If you don't see any reports listed, but you know there was a crash, you may have chosen Diagnostic and Usage Messages from the log list. Choose DIAGNOSTIC AND USAGE INFORMATION instead.
    In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.)
    Please don’t post other kinds of diagnostic report—they're very long and rarely helpful.

Maybe you are looking for