Reading A Specified Line In A Textfield
Hi!
Here is my question
- I have a Dynamic textfield with dynamic text ower serveral lines WORDWRAPs
- I need to read line by line to build up a new string so that my backend uses the same linebreaks that my flash textfield uses.
- So wat i really need to do is read line by line. Like line0 + "" + line1 + "" + line2 and so forth.
Any ideas?
FlashKit > Flash Help > Flash ActionScript
Posted on: 12-20-2004, 12:33 PM
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Reading Textfield Line By Line ? Selecting Multiple Textfields At Once ?
OK i need some serious help/advice !
I`m trying to make a sort of program like word , i want to have a text field , but the problem comes when i want to create like borders around each line of text and have DIFFERENT background colors for each line.
So i was thinking if i can read line by line and get get the height of each line by examining char by char for it's size and get the biggest one ( since my text may have different fonts sizes ect on a single line) and then have like BLOCKS that are behind each line and adjust their sizes accoring to the line size and change their color also.
Also another thing that I would also want to do , i want to create a table which i did , but now how do i put the table into my text ...and not just lie on top blocking text behind it ..how do i like "push" the text around it ?? ANY IDEAS would help...thats why i thought maybe create lots of textfields just stacked from top to bottom..but then i will have the problem of selecting them all at once like in a REAL word processing problem...and also if the text becomes too big it will need to "flow" into next textfield...
Is there ANYWAY to do this ??! HELP ME!!!!
THANK YOU
Reading Data From Text File Line By Line
I want to read some data from a text file into arrays.
In the text file, I have:
data = 1234567890
This works ok, but I want the text format in the text file to be:
data =
12345
67890
So after reading 'data', i will have 2 arrays.
[1,2,3,4,5] and [6,7,8,9,0]
Any idea how to go about doing this?
It will be even better if I dont need to use any variable.
Like this:
12345
67890
The main thing is just to read the text line by line and get them into arrays.
Thanks.
Reading A Text File, Line By Line
I am using loadVar to read in a text file for processing by Actionscript.
Is it possible to just read in a portion of it (instead of the whole thing), process it and then read in some more? Specifically, can one read in up until a linefeed?
Reading Text File Line By Line
Hy all
Got the following code:
Code:
var strContent:String;
function fillContent(folder:String):void
{
var arrayMenuItems:Array = new Array();
var arrayContent:Array = new Array();
var arrayNews:Array = new Array();
var myContent:URLLoader = new URLLoader();
myContent.dataFormat = URLLoaderDataFormat.TEXT;
myContent.addEventListener(Event.COMPLETE, getString);
myContent.load(new URLRequest("content/" + folder + "/_content.php"));
contentText.multiline = true;
trace("./content/" + folder + "/_content.php");
trace("MY DATA: " + myContent.data);
contentText.htmlText = strContent;
contentText.setTextFormat(format_ContentRegularText);
contentTitle.setTextFormat(format_Titles);
menuItemFont.setTextFormat(format_MenuItems);
}
function getString(e:Event):void
{
strContent = e.target.data;
}
What I actually need is to be able to read the _content.php file line by line. I'd like to store each line of the text file in an array (arrayContent). But I haven't found ANY solutions yet for this problem.
Best thanks for trying to help
Regards
Reading Code Line By Line?
Guys (and girls) im trying to write a bit of code which appears to shake an image on screen, however when i put all my _x &_y functions in to move it around it reads the whole block in one, instead of reading and DISPLAYING each line seperately... how do i force code to do it (in director Id use an 'updatestage' command) many thanks
Reading Last Line Of Textfile
Hello,
I am currently writing a flashscript that displays the contents of a text file.
I need to keep refreshing the data in the text file, because of data constantly being added to the text file.
Does anyone have a idea if it's possible to read only the last line of text into flash?
(because of a data size of 65Kb + it's impossible to just keep reading the text file over and over)
Reading Last Line Of Textfile
Hello,
I am currently writing a flashscript that displays the contents of a text file.
I need to keep refreshing the data in the text file, because of data constantly being added to the text file.
Does anyone have a idea if it's possible to read only the last line of text into flash?
(because of a data size of 65Kb + it's impossible to just keep reading the text file over and over)
Reading And Writing On-line Files.
Is there any way in action script to read or write a file on the internet. Like the game reads a txt file on the internet that says:
_root.fred = 1
_root.guy._y = _root.grey
And then have those changes take place in the game your playing?
Or writing a file on the internet.
And how do I protect my swf files on the internet? Sometimes when I download something it won't let me import it to flash player because it says its protected.
Reading _level0...... In Textfield
hi
im loading an external swf (admin_panel.swf)into my MC with the following code, which works. the problem i'm having is that once loaded into the MC the dynamic textfield in admin_panel.swf reads _level0.holder.new_news.
Code:
var mcl:MovieClipLoader = new MovieClipLoader();
var mclL:Object = new Object();
mclL.onLoadProgress = function(target,loaded,total) {
loada.percent.text = Math.round((loaded/total) * 100) + "%";
}
mclL.onLoadInit = function() {
loada._visible = false;
loada.percent.text = "";
}
mcl.addListener(mclL);
mcl.loadClip("admin_panel.swf",holder);
Reading One Line Of A File At A Time (ActionSript)
I'm using Perl for all of my backend database work. There are multiple
items in the database. Each item is stored on a single line which contains
all of that particular item's individual properties (such as name, price,
color, description). In Perl, I'm able to read in the entire file at once
into a single array. The array will have each line of the file (delimenated
by the newline char '
' ) as a separate index. I'm then able to
manipulate the individual values that are stored for each item within each
line.
The problem that I'm facing is that each item uses the same variable names
for its properties (ie all items have variables called itmName, itmPrice,
itmColor, etc). Therefore the LoadVariables command within ActionScript
keep overwriting each variable (ie itmName) every time it re-occurs within
the file.
Is there a method within ActionScript that will allow you to read the
contents of a file w/out automatically splitting the variables for you? Or
can you think of any other solution to my delimma?
I'll be VERY appreciative of any help at all. Thank you ahead of time,
-Nathan Chatellier
-support@ignitrix.com
I'm Gonna Cry: Reading Variables From Line In Textfile
I thought it would be quite easy to read variables from a textfile into flash, where the first line is the first variable, the second line is the second variable and so on.
I was wrong.
I already asked help in several ways but no go so I thought I might ask you, the specialists
Let me explain:
In a textfile, there are 7 lines:
Code:
&mondaystr=this is the menu for monday&
&tuesdaystr=this is the menu for tuesday&
&wednesdaystr=this is the menu for wednesday&
&thursdaystr=this is the menu for thursday&
&fridaystr=this is the menu for friday&
&saturdaystr=this is the menu for saturday&
&sundaystr=on sunday we rest&
So now I want to read those variables into flash. I use this code:
Code:
loadedText = loadVariablesNum("file.txt", 0);
var Menutoday = mondaystr;
var Menutomorrow = tuesdaystr;
var dayToday = dateToday.getDay();
Depending on the day it is, the Menutoday string and the Menutomorrow string should be calculated using a switch case thing.
Now, what's the situation:
when I create a textfield with var mondaystr, it works. Also for the other days.
when I create a textfield with var Menutoday, it says undefined?!
I don't get it. It's two days now that I'm working on this single issue and I'm afraid I'm completely stuck
Can someone help me out please?
Thanks in advance.
EDIT: maybe I should add the switch code too?
***********************************
Code:
switch (dayToday) {
case 0: Menutoday = sundaystr;
Menutomorrow = mondaystr;
break;
case 1: Menutoday = mondaystr;
Menutomorrow = tuesdaystr;
break;
case 2: Menutoday = String(tuesdaystr);
Menutomorrow = wednesdaystr;
break;
case 3: mealOfTheDay = tuesdaystr;
Menutomorrow = wednesdaystr;
break;
case 4: Menutoday = tuesdaystr;
Menutomorrow = wednesdaystr;
break;
case 5: Menutoday = tuesdaystr;
Menutomorrow = wednesdaystr;
break;
case 6: Menutoday = tuesdaystr;
Menutomorrow = wednesdaystr;
break;
}
Reading Text File Then Displaying Each Line As Seperate Movie
Reading text file then displaying each line as separate movie. Can this be done?
I want to read in my text file. eg...
Cat
Dog
Cow
Then display each line moving up the page. The purpose of this is so I can add to the text file and not have to update the flash movie. If there is anyway I can achieve this, can someone plz assist...
Cheers,
David
A Line Of My Textfield
I have a textfield and I want to just get the 3rd line of text in it. Is this possible? I didn't set any line breaks, lines are made from word wrap. So I can't just count carriage returns. Please help?
Detect Last Line Textfield ?
Hi,
Is it possible to detect the end of a textfield, for example when you read a policy and you finished scrolling, make a movieclip do something ?
TextField Line Count
is there any way to count the amount of text lines you got in a dynamic textfiled?
Y Position Of The Last Line In A TextField
I want to position something based on the position of the last line of a TextField. What's making it hard for me is that a lot of the vertical measurements are based on the number of lines, not the number of pixels.
textHeight and getCharBoundaries are both based on pixels, but I'm having trouble taking into account the scrolling offset, because scrollV is based on the number of lines.
I've been trying to use this, but it's still buggy:
ActionScript Code:
output.y+output.textHeight-output.getCharBoundaries(output.getLineOffset(output.scrollV)).y;
See, I'm trying to subtract the y value of the first visible line. But sometimes it gives me a the error "Cannot access a property or method of a null object reference" I understand that means I'm giving .getCharBoundaries a parameter it can't accept, but I can't make sure to use a legitimate character index.
Any suggestions?
Line Feeds In A Textfield
Hello,
I hace a dynamic textfield whose content is loaded from an xml file.
As linefeeds, I used
.
example :
<example><content>That examples's first paragraph
That examples's second paragraph</content></example>
The file loads properly but when displayed in my textField, linefeeds don't appear and
are displayed instead.
How can I render my line feeds? Is there any encoding to do when my xml is loaded?
Thanks in advanced,
Pascal
TextField New Line Problem
Hi, I'm using a dynamic textfield to show some text. I've noticed that when I add a text with line breaks, the result is always some more lines than I wanted... So I started setting the htmlText of the textfield and found the problem: even added as line breaks (<br>) these new lines are interpreted as new paragraphs (<p>) what causes the text seems like it have some extra lines... Here an example (exactely the lie I used):
var myTextField:TextField = new TextField();
myTextField.htmlText = '<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF">primeiro texto no sÃtio<BR>com uma segunda linha<BR>agora com três</FONT></P>';
trace (myTextField.htmlText);
This results the following output... Notice that all my line breaks were, in fact, turned into paragraphs:
<P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">primeiro texto no sÃtio</FONT></P><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0"></FONT></P><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">com uma segunda linha</FONT></P><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0"></FONT></P><P ALIGN="LEFT"><FONT FACE="Verdana" SIZE="12" COLOR="#FFFFFF" LETTERSPACING="0" KERNING="0">agora com três</FONT></P>
If I call myTextField.numLines I get 6 as the answer, not 3 as I expected... Is there a way to change this behaviour, keeping the line breaks (<br>) instead of the paragraphs (<p>)?
Thank you...
Get The Number Of A Line In A TextField
Hi,
is there a way to find the number or of a line in a textField that contains a certain string?
I can find the string using
Code:
string.search();
But then I would like to find where the line is in the textfield and scroll it dynamically.
I found
Code:
numLines
but that is only the number of lines in a textField.
thanks,
Jerryj.
Last Line Number In TextField
With bottomScrollV you got the last visible line number. But how can you get the last line number of text - invisible? I´m trying to get the text not visible in text field.
TextField Line Height
Hi guys.
Is there anyway to get the font line height of a TextField? I can't find anything in the Flash Help docs but I may have missed something.
Cheers.
Si ++
Line Number In Textfield
Unfortunatelly Flash cannot detect line number for the exact character in the textfiled (like Director can)
To resolve this I'm counting "
" (from the start till the character), but this way is bitter slow when textfileds are big.
Any opinions to do this in the other way?
Numbers On A Line In A Dynamic Textfield?
How do I make a loop like:
for(a=1;a<=10;a++)(
textfieldVar+=a; // this is wrong I know ;-)
}
where the textFieldVar will look like this;
"12345678910"
Regards
Godowsky
Get The Exact Y-position Of A Line In A Textfield
hi !
i got a problem, that makes me mad!
i want to have a listbox that uses only one textfield.
to place the selection bar at the right place,
i tried to get the exact y-position of a certain line with
the getExtent method and the leading property
of the textformat object, but i didn't get the exact
value for it.
here's some pseudo-code to illustrate that:
i=numberoftheline;
lineheight=txtFormat.getTextExtent("C");
linespace=txtFormat.leading;
y=(lineheight+linespace)*i;
this does not properly result in the exact ypos.
maybe i'm on the wrong way.
please help.
How To Use TAB Key To Indent A Line In Input Textfield
I see there are "TextFormat.tabStops" and "TextField.tabEnabled";
I put on a multi-line input textfield in my movie. However, I can not use TAB key to indent a line. When I press TAB key, it just makes my focus shift to other buttons.
Is there a "wantTab" property for textfield ?
If TAB key can not input " ", then why do we need to set tabStops ?
Line Number Of Text In A Textfield
Is there a way to get the line number of a specific string in a dynamic textfield set to auto wrap.
ex.
If a dynamic text box set to auto wrap looks like the following:
here is
some text
on different
lines
Is there a way to know that the string "some text" is on line 2?
Different Colors For Each Line In Dynamic Textfield?
Hi
I have 2 doubts regarding dynamic textField
1)How to set different colors for each line in dynamic textField?I tried
my_txt.textColor = 0xFF0000;
but this changes whole text box color
2)How to display last line in dynamic text field
can anyone help me
Thanks in advance
Find The Number Of A Line In A TextField
Hi,
is there a way to find the number or of a line in a textField that contains a certain string?
I can find the string using
Code:
string.search();
But then I would like to find where the line is in the textfield and scroll it dynamically.
I found
Code:
numLines
but that is only the number of lines in a textField.
thanks,
Jerryj.
Textwidth Of Last Line In Dynamic Textfield
Does anyone know how to determine the textwidth of the last line of a dynamic textfield?
I've got stuck. I've worked out the number of lines in the dynamic textfield with a mind to continue and find the textwidth of that last line using this value.
Alas I am stuck. Thanks in advance for any help, advice.
Steven.
HTML Images On Same Line In Textfield
Hey,
I have a dynamically text field that I want to populate with images.
I've set the text field parameters to:
my_txt.wordWrap = true;
my_txt.multiline = true;
my_txt.html = true;
What I want to do now is to have a series of images placed side by side on the same line of the textfield.
I tried
my_txt.htmlText = '<img src="_images/001.gif"/><img src="_images/002.gif"/><img src="_images/003.gif"/>';
All the above does is place the images line after line so in my text field only the last image added (003.gif) is visible.
I then tried adding width and height parameters to the images but the result was the same.
Anyone have any ideas?
Thanks
WIK
TextField AutoSize Extra Line
Hello,
If I copy a text in htmlText textfield, that is set to autoSize, an extra line is created. How can I avoid that this extra line is created?
HTML Code:
import fl.controls.Button;
var myText:TextField=new TextField();
var storeText:String;
addChild(myText);
myText.border=true;
myText.width=200;
myText.autoSize=TextFieldAutoSize.LEFT;
myText.type=TextFieldType.INPUT;
myText.multiline=true;
var myButton:Button=new Button;
addChild(myButton);
myButton.x=300;
myButton.y=100;
myButton.addEventListener(MouseEvent.CLICK, myButtonF);
function myButtonF(event:MouseEvent){
storeText=myText.htmlText;
myText.htmlText="";
myText.htmlText=storeText;
}
TextField WordWrap Causes Indent On First Line
I have a bunch of text I am working with from XML and when I import it into my text field it becomes automatically indented on the first line. Is there a way to lose this indent? If I take off word wrapping it does make the indent go away, but then of course the text spans across further than the text field horizontally.
Here are some of the properties I have assigned to the text field I am using:
ActionScript Code:
myTextField.htmlText = txtPath; //txtPath is the loaded and parsed XML
myTextField.multiline = true;
myTextField.wordWrap = true;
I'm hoping it's a simple fix.
TextField Not Showing Line Breaks
This is really weird, I have a dynamic text field with embedded fonts on the stage, with some paragraphs of text in it, I pushed enter a few times, so theres some line breaks in it...
If i test the swf, the text displays correctly. But, if i turn on bold or italic, the line breaks vanish.
So instead of
Quote:
Line one
Line two
I get
Quote:
Line one
Line two
What on earth is going on? This happens with normal fonts like Arial...
Getting The Width Of A Certain Portion Of A Textfield Line
Is there a neat way of getting the width of a certain portion of a textfield line, equivalent of the TextLineMetrics width property?
Atm I have to calculate it by splicing up the textcontent for measurement in another textfield with the same formatting, and then add it all up, which is a bit cumbersome.
Thanks!
Different Colors For Each Line In Dynamic Textfield?
Hi
I have 2 doubts regarding dynamic textField
1)How to set different colors for each line in dynamic textField?I tried
my_txt.textColor = 0xFF0000;
but this changes whole text box color
2)How to display last line in dynamic text field
can anyone help me
Thanks in advance
Line Break In Input Textfield
Hi
Something very strange here...
When I put an input textfield with "mulitlines" on my stage and publish it. I noticed when I select the field a line break is already set. So typing starts on the second line.
Any idea?
tx
tom
Retrieve A Line Of Text In A TextField ?
Is it possible to get the text on a specific line in a text field and appy it to the text property of another field?
For example, given a dynamic text field:
jack be nimble
jack be quick
jack jumped over
the candlestick
Somehow extract "jack be quick" and put it into a variable or another text field. My impression is that each line of a tex field is indexed but how can it be retrieved?
Line Break In Dynamic Textfield
I have a flash file that has several text fields that get their content from a xml document. My xml looks like this:
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<index_content>
<image no="1">
<imgLink>pages/collection.html</imgLink>
<title>Tree</title>
<text>Tree design on a olive short-sleeve t-shirt.</text>
<corner>men’s & women’s</corner>
</image>
</index_content>
The Flash file imports the xml and puts each child node of image into a separate dynamic text field that is set to except html. I want to now be able to give it line breaks. I have tried the following, but none did what I wanted it to do.
<text><![CDATA[Astronaut design on a brown short-sleeve<br/>t-shirt.]]></text>
<text>Tree design on a olive short-sleeve
t-shirt.</text>
<text>Tree design on a olive short-sleeve<br />t-shirt.</text>
<text>Tree design on a olive short-sleeve<br>t-shirt.</text>
What am I doing wrong?
Thanks for any help!
Brian
Recieves Only First Line Of Multiline Textfield In Asp
Hey
I have a form in flash where I send variables to ASP which sends an email. Everything works fine except for one thing;
The message-box which is a input-field with multiline only sends the first line of text to the ASP-script. Why is that?
/martin
Line Breaks In Input Textfield
I need to send the contents of an input textfield by GET to a php script. The problem is the input must be multiline, but cannot allow line breaks orelse it messes up the GET query. Is there anyway for me to replace the line breaks with a html encoded line break (I tried restricting the textfield to specific characters, but the return still caused line breaks)?
Cheers!
Line Height With Css For A Flash Textfield?
Hi there,
How can i set the line height of a flash textfield which is created like
Code:
function showTextContent(txtContent, x, y, w, h) {
this.createTextField("content_txt", 1, x, y, w, h);
css = new StyleSheet();
css.onLoad = function(bSuccess:Boolean):Void {
if (bSuccess) {
content_txt.embedFonts = true;
content_txt.border = true;
content_txt.html =true;
content_txt.multiline = true;
content_txt.wordWrap = true;
content_txt.styleSheet = css;
content_txt.htmlText = paginator.getPage(0);
}
};
css.load("_style.css");
}
anyone?
TextField Not Showing Line Breaks
This is really weird, I have a dynamic text field with embedded fonts on the stage, with some paragraphs of text in it, I pushed enter a few times, so theres some line breaks in it...
If i test the swf, the text displays correctly. But, if i turn on bold or italic, the line breaks vanish.
So instead of
Quote:
Line one
Line two
I get
Quote:
Line one
Line two
What on earth is going on? This happens with normal fonts like Arial...
Printing XML In Textfield In List Not Line
ve got my content to print into my text field with no XML using text();
But, it always prints in one long line. How can I tell it to line break after it prints each node?
This is basically my code right now
Code:
function ParseClients(clientInput:XML):void {
//trace("XML Output");
//trace("------------------------");
//trace(clientInput.Client.Automotive);
var clientAttributes:XMLList = clientInput.Client.attributes();
for each (var clientIndustry:XML in clientAttributes) {
clientXML.field_01.text = clientIndustry;
clientXML.field_02.text = clientInput.Client.attributes()[1];
clientXML.clientfield_01.text = clientInput.Client.children().text();
}
}
Textfield Of Single Line Can Newline
hello everybody
i have a input textfield that is set single line, it means the textfield cannt newline when i press "ENTER" key.
well..if i pressed the "CTRL" key at the same time, the textfield can newline in IE browser, but firefox can not.
why? have any solution?
thanks
Line Break With Indexof On A Multiline Textfield
I made a text field that can determine what line the user is on by looping through it and comparing it to the caret position...
i use the indexOf to determine where the linebreak is on the textfield but im not sure what ActionScript uses as a linebreak... my code works if i use "1" at the end of everthing i write and check by "1" so im sure everything else works in my code... i have tried the following and none has worked...
indxVal = strBody.indexOf('
', lastIndexVal+1);
indxVal = strBody.indexOf("
", lastIndexVal+1);
the lastIndexVal is the previous indxVal so it will skip the next one every loop...
Note: This code will work if i use "1" and end every line with a "1" so everything else is working... i think the textfield might use a different character than the '
'
Thanks in advance everyone!
|