|  | detect line break |  | |
| | | zibber |  |
| Posted: Sat Aug 23, 2008 6:55 am Post subject: detect line break |  |
Hi I wondered if anyone could help. As my deadline is looming to a dangerous point and im stuck:|
I have a dynamic text field in flash that is populated by an input box.
The dynamic text field has a maxmium width it can be. So i have it as multiline WITH wodrwap on.
My problem is that I have to send this data to server and for the php to be able to text the text and output the text as it is displayed in flash.
There seems to be no way of finding the linebreaks and passing them in the string as far as I can see? Does anyone have any ideas on this or a workaround?
The noose is tightening.
thx in advance
ade |
| |
| | | kglad |  |
| Posted: Sat Aug 23, 2008 5:42 pm Post subject: Re: detect line break |  |
| flash has more than enough string methods to detect line breaks. what's the problem? |
| |
| | | zibber |  |
| Posted: Sun Aug 24, 2008 10:35 am Post subject: Re: detect line break |  |
Hi again
The problem is that I have tried to detect line breaks in the text field and I just cant seem to get to them:|
I have tried (trace(testField.text.indexOf('\n'))) aswell as newline etc and it always returns a -1.
As mentioned in original post. The textfield is a fixed width with wordwrap set to true. I read somewhere that wordwrap somehow makes the linebreaks undetectable? I am hoping this isn't the case. All i need to be able to is send the contents of the textfield to a php page with the linebreaks included. Any help on this would be great. This is as2 targetting flashlite 2.1.
thx in advance |
| |
| | | zibber |  |
| Posted: Sun Aug 24, 2008 5:44 pm Post subject: Re: detect line break |  |
I have tried and no dice. To try and be clear I have a text field on stage say 160 pixels wide. I type copy in say a thirty h's. Say fifteen fit on first line and rest push onto second. I need to be able to send to server the linebreak flash has placed in there. /n first exist I'm there and /r only exists at the very end of the text. It's driving me nuts |
| |
| | | kglad |  |
| Posted: Sun Aug 24, 2008 10:42 pm Post subject: Re: detect line break |  |
oh. you'll need to create a custom function to do that.
duplicate your textfield and its properties (which can all be automated using actionscript) except enable the duplicate's autoSize property, don't assign text/htmlText, yet and assign its _height to be small like 10.
then start assigning text one character at a time until your textfield's bottomScroll property increments. at that point is a line break. |
| |
| | | zibber |  |
| Posted: Mon Aug 25, 2008 9:54 am Post subject: Re: detect line break |  |
| |  | |
Hi again
Firstly kglad, many thanks for your help, it is very much appreciated.
I have implemented your suggestion and it is pretty much there. However, there seems to be a slight lag in the processing which results in the pseudo line break characters being added a few characters late. Taking font embedding off the fields has improved this, but it it is still out enough that it will screw up my text rendeing when its passed to the server.
My code is as below:
origStr = orig.text origStrLength = origStr.length; currentScroll = 1 newText.autoSize = true; newText.wordWrap = true; temp_str = "";
for (var i=0; i < origStrLength; i++ ){
temp_str += origStr.charAt(i) newText.text = temp_str; amount = newText.bottomScroll; if(amount > currentScroll){ temp_str += "*" currentScroll ++; trace("insertLineBreak" + currentScroll) } }
The textfields have the same properties, namely multiline is set and thats it. As mentioend I have removed font embedding, but would ideally need this atleast for the original text box. I can work around that but the slippage in positioning of the linebreak is a real problem still. And more worrying if it is down to horsepower is this will be running on mobiles.
any further help would be fantastic |
| |
| | | zibber |  |
| Posted: Mon Aug 25, 2008 11:47 am Post subject: Re: detect line break |  |
| Doh I think I've been stupid:) in my ordering of things will confirm when home and hopefully close the thread thanks again |
| |
| | | kglad |  |
| Posted: Mon Aug 25, 2008 1:32 pm Post subject: Re: detect line break |  |
| |
| | | zibber |  |
| Posted: Mon Aug 25, 2008 1:51 pm Post subject: Re: detect line break |  |
nope, sorry kglad Im still not there:(
I cannto sem to get it right the linebreak text i place in is either 1 char or out. Code is below:
origStr = orig.text origStrLength = origStr.length; currentScroll = 1 newText.autoSize = true; newText.wordWrap = true; //temp_str = "";
for (var i=0; i < origStrLength; i++ ){
if(amount > currentScroll){ newText.text += "*" currentScroll = amount; newText.text += origStr.charAt(i) } else { newText.text += origStr.charAt(i) //newText.text = temp_str; amount = newText.bottomScroll; } amount = newText.bottomScroll; }
I know this must be something really stupid, but i just cant see it:~ |
| |
| | | kglad |  |
| Posted: Mon Aug 25, 2008 1:54 pm Post subject: Re: detect line break |  |
| why are you adding a "*" to your textfield after the line break? |
| |
| Page 1 of 2 .:. Goto page 1, 2 Next | |
|
|