Note that there are some explanatory texts on larger screens.

plurals
  1. POFlex 3 simple chat: code review request; is it good for a real life application?
    primarykey
    data
    text
    <p>i managed to put together a simple chat using flex 3 / AS3, and i want to know if it is good for a real life application?</p> <p>here is the mxml</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" creationComplete="init();"&gt; &lt;mx:Script source="code.as" /&gt; &lt;mx:TitleWindow title="Shat"&gt; &lt;mx:VBox&gt; &lt;mx:TextArea width="236" id="eShat" height="190"/&gt; &lt;mx:HBox&gt; &lt;mx:TextInput id="eMessage" enter="sendMessage()"/&gt; &lt;mx:Button label="Send" id="eSend" /&gt; &lt;/mx:HBox&gt; &lt;/mx:VBox&gt; &lt;/mx:TitleWindow&gt; &lt;/mx:Application&gt; </code></pre> <p>and code in action script (code.as)</p> <pre><code>import flash.events.Event; import flash.events.MouseEvent; import flash.events.NetStatusEvent; import flash.events.SyncEvent; import flash.net.NetConnection; import flash.net.SharedObject; var nc:NetConnection = null; var so:SharedObject = null; private var chatname:String = "mychat"; private function init():void { if(nc == null) { nc = new NetConnection(); nc.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler); nc.connect("rtmp://localhost/simplu"); } } private function netStatusHandler(event:NetStatusEvent):void { if (event.info.code == "NetConnection.Connect.Failed") { trace(event.info.code); } if (event.info.code == "NetConnection.Connect.Rejected") { trace(event.info.code); } else if (event.info.code == "NetConnection.Connect.Success") { so = SharedObject.getRemote(chatname, nc.uri, false); so.addEventListener(SyncEvent.SYNC, syncHandler); so.connect(nc); eSend.addEventListener(MouseEvent.CLICK, eSendClick); } else if (event.info.code == "NetConnection.Connect.Closed") { trace(event.info.code); } } private function syncHandler(event:SyncEvent):void { if(so.data[chatname] != undefined) { eShat.htmlText += so.data[chatname] + "\n"; eShat.verticalScrollPosition = eShat.maxVerticalScrollPosition; } } private function eSendClick(event:Event):void { sendMessage(); } private function sendMessage():void { so.setProperty(chatname, eMessage.text); eMessage.text = ""; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload