AS3 Adding Text To a Dynamic Text Field Withough deleting the original Text


#1

Greetings,

I have been trying to create a text based game were the user reads the story and will have opportunities to make choices and the outcome of the story is changed based on those choices.

My problem is I want to be able to load text into a text field on the stage over and over again while keeping the text that was placed inside of the text field the first time.

I can’t find any help with this in the help doc’s and I have looked for three hours on google. It’s possible that flash isn’t set up for this kind of thing but I thought I would try here.

Any help would be great, thanks!

Red


#2

hi, send me an e-mail with more details via my FD profile .
. always ready for freelance projects.

sincerely

OSX


#3

try this

myTF.text = myTF.text + newText


#4
try this

myTF.text = myTF.text + newText

You beat me to it :slight_smile:


#5

hi redpanda608,

have you tried:

mytext += newtext;


#6

appendText ()


#7

I can’t believe someone offered a freelance for that :confused:


#8

textField.appendText(“new text”); is MUCH faster.

In fact I think if you do:

textField.text = textField.text + newText

flash even puts in the errors tab a warning telling you to use appendText :slight_smile:


#9

Not sure if it is actually faster (cause Ive never tried), but if you think of it logically it is. Instead of removing all text first, then writing the same text again, and then adding the new text, it just appends the new text to it. Sounds about right, right?


#10

Has been introduced the appendText method just because as3 is stricter than as2 about data types… I think using += would generate an error because it would aspect numbers and not strings…

:wink:


#11
flash even puts in the errors tab a warning telling you to use appendText :)

yeah your right i hardly play with text and forgot all about appendText


#12
Has been introduced the appendText method just because as3 is stricter than as2 about data types... I think using += would generate an error because it would aspect numbers and not strings...

:wink:

nah, it works fine, it’s just not as fast. + and += operators are overloaded to work with Strings in AS inherently :slight_smile:


#13
Has been introduced the appendText method just because as3 is stricter than as2 about data types... I think using += would generate an error because it would aspect numbers and not strings...

:wink:

nah, it works fine, it’s just not as fast. + and += operators are overloaded to work with Strings in AS inherently :slight_smile:

Yes right, and I just noticed an interesting thing…

Unlike appendText(), the += operator resets the formatting of all text in the textfield to the default text format. The += operator is also much slower than appendText(), and should, therefore, be avoided.

From Essential…

:wink:


#14

Thanks a bunch everyone! I knew there had to be a simple way to do this.

If anyone is interested in seeing the game that i’m working on Check out my website at www.pandadesignforyou.com