Ultrashock Forums > Flash > Flash Newbie
trying to strip formatting from input text field

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
trying to strip formatting from input text field
Old 2009-06-28

hello,

I am not sure if I can word this correctly:
I am using Flash CS3 (but using actionscript 2.0 due to some constraints).

I have a text input box called 'chart_history' which is a multiline input text field.
When I send it to either a url or use mailto to send an email message, I get a lot of extra information about the text such as:
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">asdf</FONT></P></TEXTFORMAT>

how do I strip this out?
for the properties for the input box, I made sure that the option for 'Render text as HTML' is unchecked (and I tested with this both checked and unchecked and both times I get this).

my line to send via email:
getURL("mailto:"+to+"?subject="+subject+"&body="+body);

(where body is chart_history + <other boxes>).

thank you for looking at this.
postbit arrow 6 comments | 302 views postbit arrow Reply: with Quote   
Registered User
greebzilla is offline
seperator
Posts: 4
2009-06-22
seperator

Ultrashock Member Comments:
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2009-06-28 #2 Old  
It sounds as though you are reading the HTML from the text field instead of the plain text. Internally, Flash always uses HTML regardless of the render setting, the render setting simply changes the way the text field content is displayed.

Code:
var body:String = myTextField.text;
Reply With Quote  
greebzilla greebzilla is offline 2009-06-28 #3 Old  
is this version/actionscript version dependent?

if I trace myTextField.text, it returns undefined
if I trace myTextField, it returns the entry (plus all the HTML formatting)

the .text part does have a blue color so it does appear to be a reserved word.

var v4:String = "Complaint/history: " + chart_comp_hist.text;
trace(chart_comp_hist.text);
trace(chart_comp_hist);

I input 1234 in the box, and from the trace output:

undefined
<TEXTFORMAT LEADING="2"><P ALIGN="LEFT"><FONT FACE="Arial" SIZE="14" COLOR="#000000" LETTERSPACING="0" KERNING="0">1234</FONT></P></TEXTFORMAT>
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2009-06-28 #4 Old  
Yep, the code is AS version dependent but the code I posted is AS2 so it should be working fine.

Are you sure the chart_comp_hist variable is referencing the text field?

Running the following code will help:
Code:
trace( typeof chart_comp_hist );
Reply With Quote  
greebzilla greebzilla is offline 2009-06-28 #5 Old  
I believe it is referencing the text field correctly:

trace( typeof chart_comp_hist); returns string
trace (chart_comp_hist.text); returns undefined
trace (chart_comp_hist); returns the text I input, along with the formatting tags.

I create a text input box, then under the Var field in properties subwindow, gave it the name chart_comp_hist. When refering to chart_comp_hist in another scene, it does display the data properly within the flash file. It just gets this formatting text along with the data when I attempt to send the data from the input box to either a url or to an email.
Reply With Quote  
Nutrox's Avatar Nutrox Nutrox is offline Super Moderator Nutrox lives in United Kingdom 17 Creative Assets 2009-06-28 #6 Old  
Quote: Originally Posted by greebzilla View Post
trace( typeof chart_comp_hist); returns string
....
I create a text input box, then under the Var field in properties subwindow, gave it the name chart_comp_hist.
Ok, that is the problem. Instead of giving the text field the variable name "chart_comp_hist" give it the instance name "chart_comp_hist", the chart_comp_hist variable in the code will then reference the actual text field and not the text field content (which is what it is doing at the moment).
Reply With Quote  
greebzilla greebzilla is offline 2009-06-28 #7 Old  
ok. I was looking at another discussion on the Adobe forums, and it looks like I should be using the instance field rather than the variable field to avoid this issue. (I will need to look into the difference in use between instance and variable). Creating instance names and refering to them got around the issue.

next is trying to figure out how to convert newline to \n or some such

thank you for looking at the problem!
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: