Subscribe to RSS
get email updates
home | about | pixDif AIR app | video tutorials
polyGeek.com
polyGeek.com

Pledge drive: Help me help 360|Flex who is helping me

The 360|Flex conference is coming up soon - March 8-10 in San Jose. It seems that John and Tom - the organizers - have everything ready to go except for one little item: getting a sponsor for the USB Thumbdrive that comes in the swag-bag. They offered it to me but it's a little out of my marketing budget for RunPee.com - which is zero dollars. But they are on the hook either way so we worked out a deal. I'll start a pledge drive and try to raise as much money as I can to cover the cost of sponsoring the thumbdrive - $1,300 target. In exchange they will put RunPee.com on it. I'm not on the hook for anything except trying to raise money to cover their costs so that they don't take a loss.

We would all appreciate it if you chipped in a few bucks. I will give every dollar donated to my Paypal account to 360|Flex up until the conference is over. Let me know if you would like for your donation to be public or not because I'll keep a running tab on this page of who donated and how much.

Paypal donations to: Dan@polyGeek.com

Thanks for your support,
Dan Florio, John Wilker, Tom Ortega.

Dan Florio ( that's me )-$100, Lee Button-$100, Randy Troppmann-$100, David Ortinau-$50, Faisal Abid Founder-$55, Pintley.com-$50, Douglas Reynolds Consulting-$50, Nick Kwiatkowski-$25, Patrick McDonald-$10, Jeremy Saenz-$25, Ivan Alvarez-$25, Jen Floyd-$10, Matt LeGrand-$25, Jens Brynildsen-$25, Gates M Stoner-$20, Emerson Tyler Wright-$50, John Daily-$10, Jason Fincanon-$25, Evan Zeimet-$20 Here is a complete list of the people who have donated

Flash 9 TextFields and the added a carriage return character

June 15th, 2007 . by polyGeek

It seems that the Textfields in Flash 9/CS3 give you a little something extra: the carriage return (CR) character. It is automatically added to the end of the text value of each Textfield. Even if the Textfield is empty it will still have a CR.

This shouldn’t be a problem for most cases and only applies if you create dynamic Textfields at authoring time. Textfields created at runtime are truly empty when you create them.

The main case where you might have an issue with this is if you need to test a Textfield created at author time to see if it’s empty. If you write the following code you will get the else result.

Now if you want to test and see if the Textfield is empty you will have to do this:

Another problem you might have is if you want to append text ( someTF.text += someString ) to a Textfield created at authoring time from various locations in your code. If you don’t know when you will append first your first line of text will appear one line lower than you expected. You could solve the problem with:

You could also solve this problem with an init() function whereby you make all your authoring time Textfields equal to an empty string. If there are only a few Textfields it’s nothing to just target them individually. Otherwise you might want to do a for(in loop) like such:

There is only one problem: this will wipe out the text of any static Textfields you might have as well. You can’t give a static TextField an instance name at authoring time but they do get instance names at runtime along with all the other Stage objects: instance1, instance2, instance3, …

The only way that you could wipe out only the dynamic Textfields would be to make sure that they all have authoring time instance names and then test to make sure that the instance name doesn’t begin with the string “instance”. Here is an example:

Now you might be asking, what do I do if I have created dynamic Textfields all over the place at authoring time and I want to blank them all out in one fell swoop. Is that possible?

Well yes. Try this:

That code snippet will recursively run through every MovieClip placed on the Stage at authoring time. So this might be a kick in the pants to your startup time if you have a huge SWF with hundreds, or even thousands, of embedded MovieClips.

I’ll leave it as an exercise for the reader to make their own class out of this if they wish.

If something here has proved valuable to you then feel free to drop a couple of bucks in the tip-jar.

Post to Twitter Post to Delicious Post to Facebook Post to Reddit Post to StumbleUpon


similar posts

6 Responses to “Flash 9 TextFields and the added a carriage return character”



[...] returns New with CS3 is the added carriage return at the end of all authoring time TextFields – read read more about it.. That can cause big problems when you are reading the text value of a TextField. This little [...]

comment number 2 by: Audas

Thankyou, ……..frustrating day.

comment number 3 by: Kevin Lassard

Thank you!
I spent the entire day examining my code (which I now have to format myself since auto format in CS3 is schizophrenic). Has Adobe secretly been taken over by Microsoft or Serious Cybernetics?

comment number 4 by: polyGeek

@Kevin, nice H2G reference. Yeah, Adobe definitely wasn’t on top of their game with the TextField.

polyGeeks last blog post..Interview with Jeremy Saenz, a.k.a. The Flex Gangster

comment number 5 by: mark

Hooooooooooooooly balls this problem has been bugging me for probably like a freaking YEAR I LOVE YOU.

well my exact problem was with loading lines of text via URLLoader, but it wasn't splitting correctly because I was just splitting on "
" but now I have it doing both. yes!

comment number 6 by: polygeek

@Mark: I love it when something that I’ve written helps someone like you out. Just about everything I blog about was a pain in my ass for a while. That’s why it’s here.

   Welcome back (Change)

Leave a Reply

comment feed RSS   subscribe to this comment thread

Recent Posts

   



polyGeek.com

© Copyright 2008 polyGeek.com / Dan Florio, All Rights Reserved Except Where Explicitly Stated
Web Developement Blogs - Blog Catalog Blog Directory
M2 Websites
Local Directory for Los Angeles, CA

Better Tag Cloud