Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Flash




Line Count Of Dynamic Text Field?



Hello,
I have a dynamic text field that gets lots of different texts sent to it. what I want to be able to happen is if the loaded text goes over 3 lines some scroll bars to appear.

Is there away I can count the amount of lines in a the dynamic text box.

I have messed around with it, but all the values I get back are from the original text from authoring mode and not the dynamic txt loaded into it.


thanks
Kaan.



FlashKit > Flash Help > Flash ActionScript
Posted on: 04-17-2003, 08:56 AM


View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread

Getting Dynamic Text Line Count
Does anyone know a quick, efficient way of doing this?


I did come across a thread on actionscript.org that gave a brief explanation on how to do it, but it was for older versions of flash, and the code seemed waaay to complex for something so simple. Id like to think such a common, useful method would have been extended into the flash components in newer versions of flash.

I'm somewhat new to actionscript, but I've worked extensively in other languages, and generally, when I wanted to count the occurrences of a specific character, I just used the universal split function/method to split the string into an array and then I just retrieved the size of the array. Never tried it with line breaks though... and if this method could seemingly be possible what is the char code for a line break in Actionscript?

New Line In Dynamic Text Field
flash mx

i have a multiple line dynamic text box on stage and somewhere in another mc on the stage has a box that sets the value of that text box

on(release)
{
_root.textbox = "text here";
}

how can i do like a new line in the actionscript, so that it displays something like:

text
here

in the textbox?

please help...

Mousing Over Which Line In A Dynamic Text Field
Description
List of users will show up in scrolling text field. When the mouse is over a line of text (the usersname) it lights up (changes color for that line) and when clicked returns the text in that line (the usersname).

I did this years ago in Director using the mouseline function but I can't figure how to do it in flash. Can anyone point to an example of clue me into a way to do this?

-- thanks

Line Breaks In Dynamic Text Field
How do you do it. I basically want to be able to put double spaces between my paragraphs.

This is how my text field is set

ActionScript Code:
set (myTextField, "A bunch of text here");

Breaking Line In Dynamic Text Field
Hello guys,

Please help. I have an XML with a node, let's say like this:

Code:
<ROW text="This is a line which needs to be broken right here /n to go on from the other line"></ROW>
How can I break the line exactly where the /n is after I loaded this XML? Or how to change the XML to get this in the easiest way?
Thanks a lot for any comments, opinions, help, etc!

Poco

Target The First Line Of A Dynamic Text Field
I have a dynamic text field that is loading xml (specifically 3 lines). It loads them fine, however, I can't figure out a way to bold the first and only the first line of the text box. Is there a way to do this?

Line Breaks In Dynamic Text Field
How do you do it. I basically want to be able to put double spaces between my paragraphs.

This is how my text field is set

ActionScript Code:
set (myTextField, "A bunch of text here");

Detect A Line Break In A Dynamic Text Field
I'm bringing in some data dynamically and need to detect if there is a line break after it has been placed in the text field. If there are none, I need to reposition the text box.

Found this code on another site, but can't seem to get it to work:


Code:

lineBreak = MainMovie.Cat2.indexOf('
');

if (lineBreak > -1) {
trace("yes")
}

else {
trace("no");
}




Thanks for your help!

Multi-Line, Word Wrap Dynamic Text Field Question...
Hi gang -

I have Dynamic Text Field that receives info via .asp. The text field is set to Word Wrap and MultiLine. In my test environment I have a .txt file named the same as my .asp page which provides data to display in the field. When I test movie, the information appears as intended with multiple lines of text, no problem. When I put it "live" it grabs the info by .asp no problem, but the textfield is not honoring the word wrap/multiline settings, on the PC (which is odd in and of itself, Mac displays properly so I know the text gets into the Flash). It is basically only displaying what can fit on one line of a multi-line text field. (The display field is large enough to handle 3 lines of text.) Now I have used this process in dozens of sites doing the same thing, the same way. For some reason, which I cannot ascertain, this textfield is not working on the PC and I can't figure out why.

Has anyone else had a similar problem? I'm at a loss atm so any help is much appreciated.

Importing XML Data And A Carriage Return (new Line) Into Dynamic Text Field
Regarding importing XML into Flash, I am wondering if anyone knows a way to add a carriage return (a new line) at a certain point inside one single XML element (ie. something like: <abc> line one ??? line two </abc>. The one thing I got to work was to make my variable point to one element in the xml, then add + "

" then add text from another element. However this is annoying because for each text box I will have to know exactly how many paragraphs there are so that I can add the right amount of new lines and references to new elements when assigning the dynamic text's variables value. Any help offered would really be appreciated.

Importing XML Data And A Carriage Return (new Line) Into Dynamic Text Field
I recently read the great tutorial on importing XML into Flash at http://www.kirupa.com/developer/acti...dataflash5.htm.

I am wondering if anyone knows a way to add a carriage return (a new line) at a certain point inside one single XML element (ie. something like: <abc> line one ??? line two </abc>. The one thing I got to work was to make my variable point to one element in the xml, then add + "

" then add text from another element. However this is annoying because for each text box I will have to know exactly how many paragraphs there are so that I can add the right amount of new lines and references to new elements when assigning the dynamic text's variables value. Any help offered would really be appreciated.

HELP: How To Detect Line Number/string Under Mouse In A Static/dynamic Text Field
Hi folks,

Is there a way to detect the line number/string under the mouse in a static/dynamic text field, like we can do in Macromedia Director?

Need help urgently.

Thanks in advance.

Yossarian,
Mumbai, India.

Count Lines In Dynamic Field
how can i coun the number of lines in a dynamic text field?

Heres the reason for it :-

there is a dynamic text field say 7 lines down it has an unspecified number of lines that will be set into it what i want to do is count the neumber of lines so that if its greater than 7 i can reveal some scroll arrows else if its less than 7 you cant see the arrows.

Thanks!

Danny

Text Line Count
I have a loop running through a text string stripping out letter by letter. Is there a way that I can get the program to know when it goes onto a next line. I have ten lines of text and when it reaches the second line I want to execute another script regardless of what words are in the string.

Count Variables In Text Field
I want to be able to count how many <br> tags are in some html text that I am loading externally. If there are more than 9 <br> tags i want some custom scroll buttons that i built to appear.

Can someone point me in the right direction? How can I create an if statment to count these variables?

Count Lines In Text Field...?
Is there any possible chance to count lines in Text Field.. ?

for example...

if (myTextFieldLines > 5 ) {
do tihis and that
} else {
do nothing
}

Count The Number Of Characters In An Input Field For A Return In Dynamic Textbox
hi again everyone. this should be simple actionScript, but i cant find others with similar question.

i have two input fields. variable names are "name1" and "name2".
but when the input is returned in a dynamic text box, if the users names are too long (say "raskolnakov" and "penelope-sue"), there is no auto break in the final dynamic textbox ("both_names") and it is clipped by the frame of the movie.

so i think what i want to do is somehow count the characters in the input fields like

if the sum of the characters is more than 50,
then _root.both_names = name1 + " and " + "
" + name2;

that would return in two lines:
Raskolnakov and
Penelope-Sue

else if the sum of the characters is less than 50,
then _root.both_names = name1 + " and " name2;

that would return in one line:
Sam and Becky


thanks.

Multi-line Text Field Auto Line Break
When a Dynamic Multiple line text field is used in Flash CS3, it has a very annoying feature that auto inserts a line break at the end of inserted text. It also auto inserts a line break if no text is entered too.

I'm having a problem with this because the text is being saved from flash to a text file on the desktop. With every multi-line text field there's a nasty looking line break.

Any way of "turning off" this auto-line-break-at-the-end feature?

Word Count (or Character Count) For An Input Field
How would I create a word/character count field to count down characters used when typed into an input filed.

i.e. input field has a maxChar=255. I want the user to see the chars count down from 255, so they'll know how many they have left.

I figure it would be along the lines of wordCountField=maxChar-currentNumOfChars...would that be right?

Thanks.

Word Count (or Character Count) For An Input Field
How would I create a word/character count field to count down characters used when typed into an input filed.

i.e. input field has a maxChar=255. I want the user to see the chars count down from 255, so they'll know how many they have left.

I figure it would be along the lines of wordCountField=maxChar-currentNumOfChars...would that be right?

Thanks.

Help With Dynamic Text Count-down
Hi, i've created a repeating dynamic text count-down but i have a problem. For example, if i want the game player to have 60 seconds to play, i make a dynamic text with variable called 'count'. Then I set the variable to 60 right? And I put it in a movie clip where every second there is a 'count -= 1' and i brings down the time.

But, where i need help is how to make it so when the count-down arrives at 0, the frame of the main timeline changes (gotoframe 10). Is this possible to do by actionscript? Please help me.

Thanks

John

Trying To Pass Text From Form Text Field To A Flash Dynamic Text Field
Hi, I was hoping someone might enlighten me as to how/if I can do this...

Currently I'm using javascript which works fine to pass text from textfield A to textfield B:


Code:
window.onload=function()
{
document.forms.form1.shirtText.value=document.forms.form1.KitGroupID_16_TextOption_38.value
}
Is there a way to pass the textfield A text to a dynamic text input (flash) as I'd like to use the font embedding flash offers. I can make it work when loading a value from a txt file but I'm not sure how to access the value identified above as KitGroupID_16_TextOption_38 and make it appear in a dynamic input box. Eventually I might want to have 3 font choices for the user but I'd like to just see if I can get this working properly first.

Your help/advice would be greatly appreciated,

-Scott

Long Text Doesn't Fit Inside Single-line Input Text Field
Hi, I've been browsing these forums for a long time but this is my first post.

I'm creating an interface by which a user can design and order their own customized decal. Please see my example (I've added my script at the bottom of this post):
http://www3.sympatico.ca/sin.young/decaldesigner.html

My issues are:

1. I've set the character limit to 21, but if you were to type in 21 "W"s into the input field for whatever reason, or choose a wider font, the text shifts to the left and some of the characters become hidden as they don't all fit. I'd like to make the width of the text to always fit inside of the width of the white area. I can't figure out how to make this work.

Here's an example that does pretty much what I'm trying to describe: www.stickerjunkie.com.


2. I have the Standard Colors combo box working perfectly but can't seem to get the Fonts combo box working.

Any hints or links to actionscript tutorials/help that might be useful to my predicament is extremely appreciated.

// display colors and formatting
decalColor = new Color(decal);
color1 = new Color(decalColor);
//
function changeColor(comp) {
decalColor.setRGB(comp.getSelectedItem().data);
}
//Standard Colors array
standardcolors = [{label:'STANDARD COLORS'},
{label:'White', data:0xffffff},
{label:'Black', data:0x000000},
{label:'Silver', data:0x9c9c9c},
{label:'Gray', data:0x636b73}];

collistStandard.setDataProvider(standardcolors);
collistStandard.setSelectedIndex(0);
collistStandard.setChangeHandler('changeColor');
//
//Fonts array
myfonts = [{label:'FONTS'},
{label:'Arial', data:'Arial'},
{label:'Serpentine', data:'Serpentine'},
{label:'Enviro', data:'Enviro'},
{label:'Forte', data:'Forte'}];

fontlist.setDataProvider(myfonts);
fontlist.setSelectedIndex(0);
fontlist.setChangeHandler('');

How To Keep Text Field Text Values After Moving In Time Line?
I'm trying to to make flash application that requires the user to input data on several keyframes in the time line. I have buttons that take the user back and forth between the different keyframes so a user can input the needed data in what ever order they wish and/or go back and change it if they want.

My problems is, that as soon as the user clicks the button to go to another point in the timeline, and they come back, those input textfields that they entered data in are now empty again.

I hope that all makes sense. It seems that there must be an easy way (or even a hard way) to prevent this, and get these fields to retain the input data.

Any help would be GREATLY Appreciated!!!!!

Thanks in Advance!

Line Break Or Line Feed For Dynamic Text
I am usin a textArea so now it is different than the last post about styles.
This text is dynamic and is assigned from within the Flash file it resides.
It comes from a list selection listener and I want to pre-format it with line breaks.

Since it resides in the file I will be using a textArea with HTML on to get the line breaks.
But now I can't Style it the same way with the setStyle methos

Currently I have one line is like this.

myNotes.text = "This is Line one<br>This is another Line<br>and another line";



Any help would be appreciated.

Thank you,
WBell





























Edited: 01/24/2009 at 12:49:08 AM by W_Bell

Current Line In Text Field
I have a programically generated input text field that has an initial maximum height. This text field exists in a movie clip scrolled by a FScrollPane.

My problem is that the text field is larger than the height of the Scroll Pane such that when the user types past the end of the visible section I need to automatically scroll the Scroll Pane so that the user can always see the text that they're typing. Ideally I'd like to know the x/y coordinates of the caret so it was a simple matter of testing if it is past the bottom of the ScrollPane's viewing area.

Is there a way of determining the x/y coordinates of the caret?

Or

Is there a way of determining the current line the caret is on?

(I know you can get values for scroll, maxscroll and bottomscroll for a Text Field but this doesn't help determining the current line nor does the current caret index position as the user could use returns in the text)

Thanx for any help

Line Breaks In Text Field?
Hello everyone,

Does anyone know if there is anyway to create line breaks in a text field. I have a large paragraph of text that I am inputting through actionscript. I don't want it to scroll along until the end of the text box, but would like to instruct it where to put the line breaks. Please don't tell me I have to put a seperate text box for each line!

I'm using MX Educational (Actionscript 1.0)

Thanks
Graeme

[MX04] MAke Dynamic Text Box Count To 100
Ok I pretty much of a newb at action script although i do know the basics.
I have been trying for hours to get this:

I want to make a dynamic text box to count from 0 to 100
i want it to count faster than seconds but slower that milliseconds.
I am going to convert the dynamic text box & actions into a symbol
I just need the actions part.
The dyanamic text box is a symbol, has an instance name of Count_txt
Count_txt is linkaged for action script
Its IDentifier name is count
In the action script, when it reaches 100 i just want it to stop right there

I hoped i specified it well enough. I have been trying for hours to get it. If someone could please post the actionscript (2.0) for me that would be awsome! I will praise you forever...kinda.

If you could explain how you did it then That would be even better! but you dont have to go through the trouble if you dont want to.

Count Number Of Lines In Dynamic Text?
Is there a way to count number of text lines in a dynamic text field?

Width Of Text On The Last Line Of Multiline Text Field
I think this has been solved here:
http://www.actionscript.org/forums/s...d.php3?t=90797

However, when I paste that into Flash I get an error that says: "Attribute used outside class". Can anyone help me figure out why that's happening.. or offer a better solution for what I need to accomplish.

Ultimately, I'm trying to place a Quote MovieClip to the end of the last character in the last line of a dynamic text field.

Thanks.

Finding Line Breaks In Text Field? HOW?
I am trying to find out how to detect a line break in a block of text in a text field. Like when you press the enter key once or twice. like this:This is one,:
this is two:

There must be a way? It's not a "space" character, but something else. Anyone have any ideas? Thanks - matt

How To - New Line / Carrige Return In A Text Field.?
Anyone know how to tell a text field to go to go to the next line
( carrige return, new line , wrap around )?
thanks ahead

Space At Beginning Of Line Text Field
Hi,

I have a movie with a dynamically created textfield. I have assigned the condenseWhite property to it so that the text is treated as HTML.

However, when wrapping it sometimes breaks the line BEFORE a space rather than after it. This means the space is visible at the beginning of the next line slightly indenting the text.

Is this a known bug? Is there a work around?

Thanks in advance!

Andy

Find Line Break Into Text Field
Hi everybody,
i have a movie clip with 2 text fields (one input and one Dynamic). The user types something into the Input type textfield and by pressing a button this text moves to the Dynamic Textfield.
I use this to do it:
code:
on(release){
_root.dynamic_text += _root.input_field + "
"
}


Then from this dynamic text i want to find where there is a line break (
) to perform an action (like add something).
Does anybody knows how to do it?

Getting Width Of Second Line In A Multiline Text Field?
Hello,

I have a multiline input text field, and I'm trying to figure out a way to get the width of the input text on a line below the top line? I know how to get the width of the text for the entire amount of text the user types in, but I can't find a way to figure out the width of just the second or third line of text? Once the first line of text is full and it auto wraps to the next line, all that I can read is the width of the first line.
I've attached an image that will hopefully make the question clearer.

Any ideas?

Thanks!
Brent

[CS3] Funny Dotted Line On Text Field
working with a dynamic text field (font's embeded) that is added to the stage at authoring time (not by script). i get this funny line where the border is, although borders are set to none. Anti alias is set for "readability" -Ideas?

Find Line Break Into Text Field One
Hi everybody,
i have a movie clip with 2 text fields (one input and one Dynamic). The user types something into the Input type textfield and by pressing a button this text moves to the Dynamic Textfield.
I use this to do it:



code:



on(release){

_root.dynamic_text += _root.input_field + "
"

}



Then from this dynamic text i want to find where there is a line break (
) to perform an action (like add something).
Does anybody knows how to do it?

Single Line Text Field Scrolling Bug...
Whatever I do... It seems like this problem just won't go away. A few of my single line text fields scroll downward when there is text in them, and you click and pull the mouse downward.

It's causing problems for my users.

And, it's only random text fields that do it...

Type in some text, and then pull downward, some of the fields scroll down, some don't. I just re-created every single one... Didn't help!
http://www.designermichael.com/fbApp...eds/cpanel.php

*Note, this fla was converted from a previous version.

Content Of A Single Line In A Text Field
I am loading a hundred string values from a text field (each with a <br> after them) into a multiple line Dynamic text field set to display html. When a user clicks on any one of the lines, I want the content of that line only to be set into a variable for further processing.
any ideas on how to do this simply assuming that the loaded in data will be changing quite often?
thanks

New Line In Text Field Loaded From XML File
I dont know am I tired of what?!?!
I have problem whit new line in txt field.

This example works:


Code:

var my_str:String = "This is firs line
this is second line.";
this.createTextField("first_txt", this.getNextHighestDepth(), 10, 10, 160, 120);
first_txt.html = true;
first_txt.multiline = true;
first_txt.wordWrap = true;
first_txt.condenseWhite = false;
first_txt.htmlText = my_str;
but if I put this text in XML and load xml to flash, after trying to display text in first_txt text field flash doesnt render text with two lines, he doesnt recognize
.


I've put (<BR>) <BR> instead of
and it works but I prefer to use
.
Anyone know how to accomplish that ?

Also is there possibility to use html tags inside XML without using substitution < - < or > - > ?

Thanks for replies.
Cheers

Single Line Text Field Scrolling
I've got some single line text fields that are limited in size. When the cursor reaches the limit of the text field the cusor continues and the text scrolls off the left side and dissappears.

How can I stop this happening? I've thought about limiting the number of characters but these text fields sizes change dynamically according to how much space they need to fill. Is there a simple way around this problem?

Thanks

New Line In Text Field Loaded From XML File.
I don’t know am I tired of what?!?! :)
I have problem whit new line in txt field.

This example works:
Code:

var my_str:String = "This is firs line
this is second line.";
this.createTextField("first_txt", this.getNextHighestDepth(), 10, 10, 160, 120);
first_txt.html = true;
first_txt.multiline = true;
first_txt.wordWrap = true;
first_txt.condenseWhite = false;
first_txt.htmlText = my_str;

but if I put this text in XML and load xml to flash, after trying to display text in “first_txt” text field flash doesn’t render text with two lines, he doesn’t recognize “
”.

Thanks for replies.
Cheers

Calculating Input Text Field To Dynamic Field (easy Action Script)
hi. i'm trying to learn action script and i need help with this bit. i'm trying to use action script to calculate my brothers ages based on my own.

using flash MX. i have an input field called "my_age" and two dynamic fields called "eli_age" and "jacob_age". eli is 4 years younger and jacob is 6 years younger. i want to be able to enter my age in the "my_age" input field and then click a button that will calculate their respective ages.

here's the fla if i haven't been clear.

thanks for any/all help,
josh

Can I Sync A MovieClip To A Line In A Scrolling Text Field?
I've got a dynamic text box with a scrollBar component. The text is updated dynamically, but it's consistent text.

Now, I've got an arrow_mc movieclip that points to the first line of each paragraph as the audio hits that paragraph. Is there a way I can have the arrow scroll up and down with the textbox when the user drags the scrollbar???

Thanks!!

Static Text Field Line Height Problem
When an FLA that was created in OSX is edited on a PC the line heights in static text fields are lost. This was a problem in earlier versions of flash however it was generally fixable by republishing from the platform on which the text was originally set. As of CS3 the problem may have gotten worse:

1. I developed a flash project in OSX CS3. It included many static text fields with varying individual line heights.
2. I sent it to a colleague who was adding some tracking tags. He was working on a PC.
3. He did his bit and sent it back.
4. In the authoring environment the text looked fine. But after republishing, all the static text fields lost their line height settings - that is all the lines within any given text field inherited the line height of the first line within that text field.
5. Only text fields that were edited by my colleague were affected by this problem. Text fields that weren't edited are fine.
6. It seems that the only way to get past this problem is to actually delete these text fields and create new ones. This would take about a week. Republishing doesn't work.

Any ideas?

Getting MySQL Field Data Into Dynamic Text Field In Flash
Hi, im having some trouble as to how to retreive data from a mySQL database field and putting the values into a dynamic text field in Flash... im quite new to this so any help will be appreciated! thanks.

[F8] MySQL Field Value Into Dynamic Text Field In Flash
Hi, im having trouble as to how to retreive a value in a field of a MySQL database and putting it into a dynamic text field in flash... i have no idea as how to do this... any help? thanks

Asp Database Field Loaded Into Dynamic Text Field -HELP
Hi all,
after much trial and error and still having troubles i thought i would ask people that maybe know what there doing.
Im using Flash 8 pro, and have placed textarea component on stage and gave it an instantce name, need to pull a single record from a record database using asp.

This is my approach but if there is an even easier way let me know.

I have created the following pages.
webpage.asp (end result web page that shows the text field to user)
script.asp( asp script that sends data back/forth to flash

i used the FlashVars param to pass a variable into the flash movie.
variable is named auto_num. im using this to then pass it back out of flash to filter the recordset.

then on the flash movie.swf. all on root level. i have the following code

var text_value; //(this is the value sent back from asp page string)
//not sure if i needed to declare it but did anyways.

var_sender = new LoadVars();
myData = new LoadVars();

var_sender.auto_number = auto_num //(auto_num is loaded flashvars param)

myData.onLoad = function() {
my_text_1.text = this.text_value
};
myData.sendAndLoad("http://www.********.com/script.asp", myData ,"POST");

on the script page i have a record set that filters for form variable named auto_number. all of code is in asp. I call a response.write to write the text_value back to the flash movie.

here is the heart of the script.asp code. not showing the record set filtering stuff.

<% Dim text_value
text_value = "text_value="&(Recordset1.Fields.Item("long_des"). Value)

response.write(text_value)
%>

but i get undefined and can never get the variables to load into the flash movie. i want to export as flash player 6 or 7. what am i doing wrong here?

So in a nutshell, i have an asp page that shows a record and would like to display the long description field of that record in a flash dynamic text box.

I can make it work by passing the entire long description from record set within the flashvars param but that seems like a real clunky way to do it pasing that much text within the flashvars param.

Does anyone know of simple database connectivity kits that extend flash for the semi-programmer guys?

Copyright 2005-08 www.BigResource.com, All rights reserved