Widow and line break TextField

Hello

In a TextField with multiline set to true, how can I find where the text has a line break?

I want to find the breaking point and then find a "widow", I want to find out how many words after the line break. I heard that the text field creates a software interrupt.

I believe that this is the position of the soft line break-

textField.text.indexOf('\r')


Then I have to get the string after that position.


Then get an array of the words in this chain, something like this-

String.Split(/\w | ' | (/ IG);


Can anyone share any advice or solutions?


DJ Gecko says:

Hi Kglad,

Thanks again for the help. I had to make some changes so that it can work properly.

public static void countWords(tf:TextField,_s:String):Vector.

{

var returnA:Vector. = new Vector. ();

var textA:Array = s.split(' ');

var save: String = tf.text;

TF. Text = ";

var num_line:uint = 1;

var wordCnt:uint = 0;

for (var i: uint = 0; i< texta.length;="">

{

tf.appendText (textA [i] + "");

wordCnt ++;

If (tf.numLines! = num_line)

{

the last word added to the created text field a new line

We do not want to include this last word to our word count for the previous line

-wordCnt;

returnA.push (wordCnt);

num_line = tf.numLines;

Since the last added word created the new line, we add it to our account

wordCnt = 1;

}

}

If there is a single line, we need. If there is more than one line, then this is the number of words to the last line

returnA.push (wordCnt);

TF. Text = saves;

return returnA;

}

glad to hear that you guessed it work.

Tags: Adobe Animate

Similar Questions

  • Causes of white space, tab, and line breaks slow in running the queries? What is the main reason behind it?

    Hi all


    I am facing a weird problem in the SQL query. Taken, I wrote the request with the spaces, tabs and line breaks after execution it slows down the database and finally, I have to restart the database again. But after removing the spaces the application went very well. I don't know what the problem causing this slow run, but after the removal of whitespace to query everything works fine. I've also confirmed plans to explain the two after the removal of whitespace and previously had the same results.

    I use the TOOL of DEVLOPER PL/SQL, SQL developer, Toad and Oracle 11 g.

    ***************************************************************

    For example. (in reference to my original query):

    Select

    *

    Of

    Double;

    ****************************************************************

    (After removing whitespace)

    Select * twice;

    *****************************************************************

    What would be the reason for white spaces causing slow performance?

    Please let me know if you need additional information on my question.


    Thanks in advance,

    HP

    If you make the first request without spaces and the second by spaces you will see, the second is even faster...

    The reason why are cached revenge...

    HTH

  • visible indents and line breaks

    CS5

    some how I hit something on my keyboard and now all my line breaks and the dashes are visible, how to disable this

    Click on ctrl-shift-8.

    p.s. Please check the useful/correct.

  • regexp_replace and line break characters

    I'm using regexp_replace to an insert in a string with the following format: "A", "B", "C", "D"... I'm inserting a DLJP prefix for each element so the end result would be "DLJPA", "DLJPB", "DLJPC" etc. The regular expression, I've provided works fine however it's strip between the chain line break characters.

    Select regexp_replace ('"A", "B", "|") Chr (13) | Chr (10) | ""C","D", '(^|,) \s*\"', '\1"DLJP') of the double".

    Result should be (with intact line break):
    "DLJPA", "DLJPB".
    "DLJPC", "DLJPD".

    but instead the result is:
    'DLJPA', 'DLJPB', 'DLJPC', 'DLJPD '.

    I want to KEEP the original line breaks. I don't know why he is stripping on the CRLF because I'm not including the CRLF in the regular expression pattern. By documentation the ^ does not, unless I specify'm ' as the match parameter. In any case, it deletes line independently, breaks even if I omit corresponding ^.
    select regexp_replace('"A", "B",' || chr(13) || chr(10) || '"C", "D"','"([^"]+)"','"DLJP\1"') from dual
    /
    
    REGEXP_REPLACE('"A","B",'||CHR(13)|
    -----------------------------------
    "DLJPA", "DLJPB",
    "DLJPC", "DLJPD"
    
    SQL>
    {code}
    
    SY.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            
    
  • Help with string.split() for line breaks and spaces

    What I'm trying to do is to take a series of numbers and convert it to a table, while cutting the numbers, aren't. Here's the format:

    1.0000000E + 000 + 000 1.3668423e

    1.0000000E + 000 + 000 1.3668423e

    1.0000000E + 000 + 000 1.3668423e

    ...

    So it is basically: space, space, digits, space, space, numbers, line break

    Right now I am using the following code (myString is a string, and dataSet1 is an array):

    var reg: RegExp = new RegExp ("\n");

    myString = textLoader.data;
    myString.split (reg) = dataSet1;

    I tried ("\n\s") and ("(\n)(\s*)") and many other combinations, but I can't seem to figure out how to make multiple conditions in a regular expression. All I need to do is to remove all the spaces and line breaks and I should be good.

    I appreciate any help, thanks.

    You can use the Array.map method to convert your strings. Something like this:

    function str2Num(element:*,_index:int,_arr:Array):Number
    {
    Return Number (item);
    }

    var arr:Array;

    ARR = myString.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s + /);

    ARR = map (str2Num, null);

    or combine them all in a single statement

    ARR = myString.replace(/^\s+/,"").replace(/\s+$/,"").split(/\s + /) .map (str2Num, null);

  • Line breaks not succeeded since flash to ASP.

    Hello

    I came up with a very annoying problem, and I need it fixed ASAP.

    The problem is as follows:

    I have a form in flash that contains a number of areas. One of these is an input field in order to capture impressions of the user on a given topic. Needless to say that this impression may contain paragrafs and line breaks. I use flash 7 publish settings and passing the values of fields via LoadVars. The problem seems to be that no line breaks is passed to ASP. All special characters are passed correctly, the HTML code is encoded in UTF-8 format so that Portuguese characters are correctly decoded, but without line break is shown. I need a quick fix to solve this problem the line breaks.

    Can someone give me a quick hand on it?

    THX

    THX kglad,

    Your solution is very simple... so much so, I happened to create a solution on a much more complicated way... I found myself escaping chain, detect where the 0% D was found and replaced it with
    . A way that is much harder to get the same result... Opportunities future im going to use your solution, which is a much simpler way and does not require the number of lines that I had to create for the same purpose of coding.

    Thx to new m8

  • Line breaks ignored when using text HTML CSS and embedded fonts

    Someone at - it find it.
    When you use a style sheet with html text in a dynamic textfield with embedded fonts line breaks are ignored. It's as if TextField.condenseWhite is set to true. Essentially the < p > tags are treated as a < br / > tag.

    If I do not incorporate fonts, it works fine. Another weird thing is that if I add an empty paragraph < p > < / p > between the first two paragraphs it makes any following paragraph behave correctly. for example

    < p > first text paragraph here < /p >
    < p > second text paragraph here < /p >
    < p > third text of paragraph here < /p >

    poster as if there are < br / > between each of them.

    But

    < p > first text paragraph here < /p >
    < p > < / p >
    < p > second text paragraph here < /p >
    < p > third text of paragraph here < /p >

    behaves correctly even for the third paragraph.

    Here is the code that I work with (by using XML as I am filling dynamic textfield to XML)

    any help much appreciated

    UPDATE:
    After reading http://www.kirupa.com/forum/showthread.php?t=307326
    I tried the same experiment using a TF designed in the IDE, the results for each, although the TextFields are essentially the same are totally different.

    Updated CODE accordingly - just need TF on stage, called "ideTextField" with the font "Arial".



    Ok
    I gave up to play with style sheets, try display: block, inline, different ways to format the XML data, in play with XML.ignoreWhiteSpace and XML.prettyPrinting etc.

    I went down the road of encodeURI, using a regular expression to remove all tabs, line breaks and the transport returns. This now gives consistent results for all situations, even incorporated and any fonts embedded.

    for example
    _TEXT:string = TEXT FROM XML, HTML TEXT etc.

    var st:String = encodeURI (_text);

    var model: RegExp = /(%09) + | (0 %) + | (0 % D) + / g ;

    St = st.replace (model, "");
    St = decodeURI (st);

    YOUTEXTFIELD.htmlText = m;

    The

    Tags always behave like a
    Tag, but you can add an extra
    to simulate a paragraph.

    Here is the example with the updates,

    Hope this helps someone

  • In v31.0, I can view is more 'raw' XML files with line breaks and ' &lt; ' and ' / &gt; ' characters. Is there a setting that will give me this option?

    Until a few days ago when I opened a file XML with Firefox, I see the content of the file appears with line breaks and ' < ' and ' / > ' and elements. Like this:

    fixed image in < typeOfResource > < / typeOfResource >

     <genre authority="marcgt">picture</genre>
     <genre authority="nmc">Print, Photographic</genre>
     <originInfo>
       <dateIssued encoding="marc">1884</dateIssued>
       <dateIssued encoding="marc">1884</dateIssued>
       <issuance>monographic</issuance>
     </originInfo>
     <language>
    

    Now, it will display like this:

     still image picture Print, Photographic 1884 1884 monographic eng electronic
    

    No tags or line breaks. I need to see the entire XML file. How can I configure FireFox to display this for me? One of my colleagues uses v31.0 and XML views with tags and the line breaks for him.

    For example, I was looking at files sitemap.xml (search Google for inurl:sitemap.xml). For those who have not declared a style sheet, you should always see the classic "source highlight: presentation

    Example: http://www.website.com/sitemap.xml

    Are the files that don't appear as similar planned by not declaring a style sheet?

    As a temporary workaround, you can view the source to see the original. Either:

    • CTRL + u
    • Right click > view Page Source
  • Easy way to remove excess line breaks in txt, html, and epub files?

    Transfer to my e-reader to read web pages. I have to convert everything in epub, because the PDF files and djvus are designed for larger screens, and txt and html are not displayed correctly.

    In any case, some pages have a lot of extra newlines that are arranged for larger screens.

    I have to remove the line breaks to make it readable. I know that DevonTech wordservice works in txt, which I can convert it to Epub. Is there something that works in Epub itself? Is there something else that works in txt?

    Thank you.

    INTHE html, these line breaks appear to be either < br / > or < br / > where the paragraph breaks are < p >. So, it seems easier to edit files ePub in the editor, as the iWrite series Epub or the caliber, that the modification of the txts.

  • I need to find all of the XML elements and add a line break for the text of each of them

    I need to find all XML elements and to add a line break the text of each of them.

    Is it possible with a script?

    Try this piece of code as it is. I hope that's what you want...

    var myDoc = app.activeDocument;
    var inddRooElement = myDoc.xmlElements.item(0);
    var xPathElements = inddRooElement.evaluateXPathExpression("//*");
    var elementCount = xPathElements.length;
    for(var eId=0; eId
    

    ----------------

    Green4ever

  • Problem with XML and different line break styles

    I'm working on a project that is being developed by some developers Flash Builder 4.6 running in Windows and some developers Flash Builder 4.6 running under OSX. We have difficulties due to the difference of newlines between the two environments. In an .as file with line breaks in style UNIX is similar to the following code:

    var XML = < document >

    < item >

    < / item >

    < / document >;

    xml.appendChild (SomeClass.getXML ());

    SomeClass.getXML () is located in a file .as using type line breaks Windows and is similar to the following:

    public function getXML (): XML

    {

    var moreXML:XML = < anotherElement >

    < childElement >

    < / childElement >

    < / anotherElement >;

    Return moreXML;

    }

    When the XML object is serialized and written to a file on a Windows computer, it looks like this:

    < document >

    < item >

    < / item >

    < anotherElement >

    < childElement >

    < / childElement >

    < / anotherElement > < / document >

    Line for all outside anotherElement breaks are of the form \r\n. Line breaks it contains are of the form \r\r\n, causing thus the empty lines. I'm guessing that the odd line breaks are the cause of the strange setting indented, as well. None of these problems occur when XML is added to the xml file .as that employees style UNIX line breaks.

    Is it possible to force the Flash Builder to use UNIX on Windows style line breaks? Otherwise, there are relatively specific to this problem solutions? Thank you!

    Section clarified

    I found a setting to force a certain style of line breaks: window-> Preferences-> General-> Workspace (delimiter line of file new text). The XML serializes as planned today.

  • Use of line breaks and breaks

    I just experimented dates PHP and found most of the following code on the php site:

    <? PHP

    echo strtotime ("+ 1 day"), "\n";

    echo strtotime ("+ 1 week"), "\n";

    echo strtotime ("+ 1 week 2 days 4 hours 2 seconds"), "\n";

    echo strtotime ("next Thursday"), "\n";

    echo strtotime ('+ 3 months'), "\n";

    ECHO ("< br >");

    ECHO ("it was a break < br >");

    ECHO ((isset($_SERVER["request_time"]))? $_SERVER ["request_time"] ":" "")

    ? >

    < br >

    <? PHP

    $date = new DateTime('2000-01-20');

    $date-> void (new DateInterval ('P10D'));

    $date-> format('Y-m-d') echo. "\n";

    ? >

    < br >

    <? PHP

    $date = new DateTime('2000-01-20');

    $date-> Add (new DateInterval ('P6M'));

    $date-> format('Y-m-d') echo. "\n";

    ? >

    < br >

    <? PHP

    $date = new DateTime();

    $date-> format('Y-m-d') echo. "\n";

    Echo "no line breaks shown."

    ? >

    None of the < br > or "< br >" code ws originally included.

    The result of this is:

    1332149953 1332664753 1332851955 1332374400 1340008753

    It was a break

    1332063553

    2000-01-10

    2000-07-20

    2012 03-18 no line breaks shown

    ___________________

    The code "\n" seems to do nothing.

    If I replace it with "< br >" I get what I expected.

    So, what is the purpose of "\n" and when (if ever) can or has it be used. ?

    A newline character is considered whitespace and HTML treat whitespace as a single space. You can use the newline character, if you create a file or an email.

  • XML, CSS, tabs and unwanted line breaks

    Hello

    I spent days trying to fix this... including many hours of trawling the web, but nothing helped so I hope some of you can help out.

    I have a site that compiles to Actionscript 2.0 and Flash player 8.  This site uses the XML output from ASP.Net pages of database-oriented.

    The problem I have is basically where I have a tabstops set, in some cases, where the text from the first tab stop is over a certain length, a unwanted line break is released just before the last word in the entry.  (I know it's always the last word if I put a word on the end of the word chain that was originally on the new line being back in its place - so it doesn't seem to be associated with length).

    Indeed, what I want is as follows:

    Header1: descriptive text in the header 1-tete2: Description 2 header

    header3: Description 3 header4 header: header text 4

    text description here on multiple lines

    I mean, it is something like this:

    Header1: descriptive text in the header 1-tete2: Description 2 header

    header3: with a long Description 3 header

    Description header4: header text 4

    text description here on multiple lines

    I am loading Xml is as follows (this has been anonymised and rafters has changed to "[]")

    [? xml version = "1.0" encoding = "utf-8"?]
    [config scrollPosition = 'right' styleSheet=".\stylesheets\cv.css']
    [text]
    [textformat tabstops = "50,540,590"]: [tab /] T [tab /] T [tab /] T [tab /]: [br /]
    [list_by] Entered Date of CV [/ list_by]
    [br /]
    ["headertext"] Date: [/headertext]
    [tab /]
    [itemheader] September 2010 - March 2011 [/itemheader]
    [tab /]
    ["headertext"] Agency: [/headertext]
    [tab /]
    [itemheader] [a href ="http://www.xxxx.eu/xxxx.cfm"target = "_blank"] xxxxx [a] [/itemheader]
    [br /]
    ["headertext"] Role: [/headertext]
    [tab /]
    [itemheader] ABAP programmer Application Maintenance SAP ECC 6.0 Finland [/itemheader]

    [tab /]
    ["headertext"] Company: [/headertext]
    [tab /]
    [itemheader] [a href ="http://www.xxxx.com"target = "_blank"] xxxxx [a] [/itemheader]
    [br /]
    [br /]

    There are closing tags appropriate further down in the file.

    The CSS that relates to this is:

    HeaderText {}
    display: inline;
    color: #008000;
    }
    ItemHeader {}
    display: inline;
    color: #FFFFFF;
    }
    {list_by}
    do-size: 11pt;
    text-align: center;
    }
    {to preamble
    do-family: verdana_italic;
    text-align: justify;
    margin left: 150px;
    right margin: 150px;
    }
    {sum_title}
    text-align: center;
    do-size: 11pt;
    make-weight: bold;
    color: #FFFF00;
    }
    {text}
    do-family: verdana;
    do-size: 9pt;
    color: #FFFFFF;
    }

    And finally the Actionscript code:

    content_mc.scroll_txt.setTextFormat = tFormat;
    content_mc.scroll_txt.embedFonts = true;
    content_mc.scroll_txt.html = true;
    content_mc.scroll_txt.WordWrap = true;
    content_mc.scroll_txt. Multiline = true;
    content_mc.scroll_txt.condenseWhite = true;
    content_mc.scroll_txt. StyleSheet = myCSS;
    content_mc.scroll_txt. Text = sXml;

    In order to get the CSS work around the dynamic text field settings, I use an empty TextFormat object tFormat.  The XML is loaded with ignoreWhite set to true.

    Anyone any ideas?  Or I do not see the wood for the trees?

    Concerning

    Rich

    as I said, it may be a bug.

    and "unexpected" wasn't a good choice of words.  I expected because I'm familiar with the issue, but you're right, I wasn't expecting when I first met it.

  • CFFILE - reading text file and maintenance of line breaks

    I am using cffile to read a text document, then add then display the content of the text document in a file .xml for an atom feed. Everything works fine, but it seems that cffile is stripping on the line breaks in the original file so that the contents of the variable which is save has more no line breaks. Is there an attribute that I'm missing that will control this behavior or I have to go about it in different ways. Thanks in advance for any idea on this issue.

    Why do you say that line breaks are removed?

    If you just say that because when you look at the results in your browser.  Recall that the HTML standard ignores all the line breaks and most other white space.  A quick overview of the source will tell you if the line breaks are there or not.  Using the HTML code

    ...
    Tags is the right way to tell a browser not not to ignore white space in the source.

    But it is possible that somewhere along the process of conversion of text file to XML data line breaks are stripped.  But then, we would need to see significant process pieces for a chance to help you.

  • HTMLEditFormat/HTMLCodeFormat with line breaks and newline

    I seeks to some user entered the information on the screen and hit my a problem of output formatting. If I use HTMLEditFormat(), I lose all the line breaks, but that Word wraps nicely. If I use HTMLCodeFormat(), I get line breaks, but the text isn't as word wrap, making some really large screens, even if I put the information in a table with specific to a specific width defined. Is there a way to get the best of both worlds? I need to be able to keep line breaks (sometimes they seized lists or have several paragraphs) but want to word wrap too so that it is easy to read without scrolling sideways. Any ideas?

    Thanks for your suggestions. Given that the information is entered by external users and displayed to the public, I use HTMLEditFormat and HTMLCodeFormat to help prevent script attacks, so don't really want to drop them altogether. However, I discover after playing with the suggestion listed here, it will work: #Replace (HTMLEditFormat (mytext), chr (10),')
    (', 'all') #.

    HTMLEditFormat gets rid of the carriage return character, but not the line supply, so it is possible to replace line breaks with
    to create the desired effect.

    Thanks for your suggestions.

Maybe you are looking for

  • My MacBook 2015 12 "retina screen went black, all this experience?

    My MacBook 2015 12 "retina screen went black, all this experience?

  • Lack of disk space

    Hi all I have a problem with my SSD 512 GB on my Macbook Pro retina 2013. 80 GB are missing and I do not know where... I've looked everywhere, I have no other partition on my Macintosh HD (2 years ago I used BootCamp with Windows, then removed and al

  • Where the Notes files are stored

    Hi all Today, I have reinstalled my MacBook Pro 2015, but I can't find how to restore my notes. I did a lot of research on the internet and found where the notes are stored in the library (where are stored the Notes files?), but it seems that this tr

  • Necessary driver PCI device

    Hello I have a HP Pavilion g6 running Windows 7. She used to detect my HD card but I had to have the hard drive replaced and it does detect it anymore. It does not find any PC device driver. The hardware ID are: PCI\VEN_10EC & DEV_5209 & SUBSYS_16701

  • How can I stop combatarmes crashing on login

    How can I stop the fight weapons crashing on login. can you help me