I've been playing with Flex (as you may have heard) and I thought to myself 'why not jump in at the deep end and build something that works with Flash Media Server'. What I came up with (and what is work in progress) is this Flex audio chat app. Basically a text chat application which also support push to talk functionality - no video right now, just audio and text.
I've learnt a lot from building this, most notably:
I've learnt a lot from building this, most notably:
- There is now a client property for objects such as NetConnection and SharedObject, you need this to tell Flex where to direct callback methods to (so there's no more nc.doThis() - oh no). Thanks Owen
- To make individual properties in an AS3 class bindable use custom events for each property. Something like
[Bindable (ChangeEvent='histChange')]
public var chatHistory:String = ""
Thanks Johannes, you are the official Bindings-meister (no, not bondage!), who btw hasn't blogged since October 4th ;-) - If you are using a custom MXML itemRenderer (I did for my userlist) and want to inject some conditional logic into it, override data's getter/setter (I did in usersRenderer.mxml but couldn't have doen it without Tink, the IM oracle and Community Experts Expert).
- FIXED In order to get a TextArea component to scroll all the way to the bottom programmatically you need to some weird sh*t. One would have thought that verticalScrollPosition = textField.maxScrollV may do the trick but no - this.validateNow(); is needed also.
BUT STILL: while the last line of text is now visible, the scrollbar won't go right down (see pic). What's going on there? Any ideas? (NOTE: this has now been fixed, check comments for details). Thanks to mr for the validateNow() guidance.

So there you go, Flex with live audio, and no I have no idea how well it scales. BTW I am sharing the sources for the text version only - no audio right now as this may turn into a commercial project - sorry. But I do hope you learn a lot from my code and my mistakes, and the audio part should be fairly easy to add.
Check out FlexAudioChat


<mx:TextArea id="txtChatBox" styleName="chatBox" editable="false" updateComplete="txtChatBox.verticalScrollPosition = txtChatBox.maxVerticalScrollPosition + 1;" width="100%" height="100%"/>
The code was taken from my Flex Chat example, http://renaun.com/flex2/red5/BasicChat.html
function scrollBug() {
myTextArea.vPosition = myTextArea.maxVPosition;
}
// when you update de content of the textArea:
myTextArea.doLater("_root", "scrollBug);
Renaun, I have used your tip to modify my ChatTextarea mxml component which extends TextArea. I added this to the constructor:
addEventListener("updateComplete", onUpdateComplete);
and this to a private function onUpdateComplete:
this.verticalScrollPosition = this.maxVerticalScrollPosition + 1;
Works a treat.
Many thanks.
sorry but your question is a little complex to explain in a blog comment. I hope you'll figure it out yourself. Check the tutorial section for an article on private messages though.
I live in Brazil and am learning Flex 2,0 and FMS now, I would like to know if you have as to order the code to me I to study, with the audio one in functioning, congratulations for the great content!
are you wanting to buy the source files for the Flex Audiochat?
I was thinking on adding the audio part to your text-chat, but I have some doubts.
I know netstream is one side only, if you talk you can't hear, so I suposse you must define, at least, two stremas, one for listen and one for talk, but... how can all users talk and listen each other? Have you to open one stream for each user to talk and connect any other users to these streams to listen?
All the samples I have found use comm components from flash ide, but I need to make this on flex, so these does not help me.
Thanks,
Jesus
In order to let each user hear every other user I simply create a new NetStream for each user who is currently speaking.
So every user who speaks sends one stream. Every listener opens one stream per for each broadcasting user.
That was what I was thinking but I have another doubt about performance.
on client, what happens when you got i.e. 30 users? each user has to subscribe to 29 streams.
and on server? 30*29=870!!! connections.
have you made any test?
Thanks again,
Jesus
My particular application is not likely to be popular enough to suffer from this problem however.
I messed up somehow - why has nobody noticed this before?
My old code from this app has been refactored so this class I post now *should* work but I cannot say for sure that it will... In any case it has the stream references in it. No idea what happened to the original, correct class...
http://www.flashcomguru.com/apps/flex/flexaudiocha...
If you're on this topic, don't you know that how to stream the video of an IP cam via flash? Does it have 'hacks in it' or is it as easy as... very easy...
Thx for your answer
Respect++ for this code, ifrozen
St
Use your flex audio chat, but I can not quite make it to work.
I wanted to ask so if you could help me because they are the first steps with flex.
Thanks.
sorry for my bad english
is - call validateNow();
I have tried to integrate your text chat with Renaun Erickson conference app for my class project, but since this is my first time using flex/fms/as, it turned to be a disaster. I am interested in purchasing the code so please contact me when you get a chance.
Thank you
I am interested in an audio/text chat only.
I read your post and would like to know how we can use it for our small company. Rent or buy... Can we discuss and are you interested?.. I am looking into various chat apps and yours, on its face, appears to fit our needs. I would only need to ask some questions, if you are amenable.
Thank you!
Ana