Hi there,
I need to implement very high performance text field for chat purposes.
- I need that my chat messages appeared at the top of the TextField
- I need the ability to click on a text and that it worked as a link
- I need the ability to select all text in chat.
In my current implementation I am using TextFild and htmlText attribute to set html formatted text + i am also using <A> tags for link purposes.
When my chat text field is getting a message it creates a string missingText and puts this message into it.
Then a start the timer for updating my chat field (0.1 second)
If one more message will come to chat before this timer is hit then I just append this text at start of the missingText.
When the timer is hit I am making new string by adding missing text at the start
missingText += allChatText;
Add then I reRender the html in chat.
textField.htmltext = missingText;
I also added the limit of characters that chat can render and in combination with timer it seemed pretty descent, but still NOT good enough. (Some updates (50 messages per second) could take 0.1s and in this time flash seems to be in buzz state)
Currently I have the idea to create my own custom html rendering that is based on TextFormats.
When this new chat textfield will get the messages it will parse it and produce text blocks that then will be decorated with needed TextFormat.
So the message NoneUser: Hi all! Will be splitted to “NoneUser:” and “Hi all!”
That I add “NoneUser:” at start of the textfield -> then I decorate it with need textformat by calling setTextFormat(0, length, NeededFormat) and then doing the same with “Hi all”
For the link clicking detection I will use getCharIndexAtPoint and then use getTextFormat to determinate its text format and then by this format I will guess on what king of text I clicked and call needed method.
So my question is:
How do you think will second implementation be faster?
Any suggestions or thoughts on how to make such fast chat TextField implementation will be appreciated.