Цитата:
|
Скажите что вы используете.
|
Что вы имеете ввиду?
Если вам интересно вот мой код.

Код AS3:
import flash.events.Event;
var history:Array = new Array();
var nc:NetConnection = null;
var textchat_so:SharedObject = null;
var lastChatId:Number = 0;
var chatSharedObjectName:String = "textchat";
var chatText:String = "";
function ncOnStatus(infoObject:NetStatusEvent)
{
trace("nc: "+infoObject.info.code+" ("+infoObject.info.description+")");
if (infoObject.info.code == "NetConnection.Connect.Success")
{
initSharedObject(chatSharedObjectName);
}
else if (infoObject.info.code == "NetConnection.Connect.Failed")
{
trace("Connection failed: Try rtmp://[server-ip-address]/textchat");
}
else if (infoObject.info.code == "NetConnection.Connect.Rejected")
{
trace(infoObject.info.description);
}
}
function doConnect()
{
// create a connection to the wowza media server
nc = new NetConnection();
// trace connection status information
nc.addEventListener(NetStatusEvent.NET_STATUS, ncOnStatus);
trace("connect: "+MovieClip(root).serverUrl);
//chatSharedObjectName = connect.soNameStr.text;
nc.connect(MovieClip(root).serverUrl);
}
// format the text chat messages
function formatMessage(chatData:Object)
{
var msg:String;
var currTime:Date = chatData.time;
var hour24:Number = currTime.getHours();
var ampm:String = (hour24<12) ? "AM" : "PM";
var hourNum:Number = hour24 % 12;
if (hourNum == 0)
{
hourNum = 12;
}
var hourStr:String = hourNum + "";
var minuteStr:String = (currTime.getMinutes())+"";
if (minuteStr.length < 2)
{
minuteStr = "0" + minuteStr;
}
var secondStr:String = (currTime.getSeconds())+"";
if (secondStr.length < 2)
{
secondStr = "0" + secondStr;
}
msg = "<font color='#999A4C'>" + chatData.user + ": </font>" + chatData.message;
return msg;
}
function syncEventHandler(ev:SyncEvent)
{
var infoObj:Object = ev.changeList;
// if first time only show last 4 messages in the list
if (lastChatId == 0)
{
lastChatId = Number(textchat_so.data["lastChatId"]) - 4;
if (lastChatId < 0)
{
lastChatId = 0;
}
}
// show new messasges
var currChatId = Number(textchat_so.data["lastChatId"]);
// if there are new messages to display
if (currChatId > 0)
{
var i:Number;
for (i=(lastChatId+1); i<=currChatId; i++)
{
if (textchat_so.data["chatData" + i] != undefined)
{
var chatMessage:Object = textchat_so.data["chatData" + i];
var msg:String = formatMessage(chatMessage);
var clip:MovieClip = new messageMc();
var newMessage = chatList.allMessages.addChild(clip);
newMessage.txt.htmlText = msg;
history.unshift(newMessage);
}
}
lastChatId = currChatId;
}
}
stage.addEventListener(Event.ENTER_FRAME, function(){
if(history.length!=0){
history[1].y=0
for(var i=1; i<history.length; i++){
history[i].y= history[i-1].y+history[i-1].height+5
}
}
});
function connectSharedObject(soName:String)
{
textchat_so = SharedObject.getRemote(soName,nc.uri);
// add new message to the chat box as they come in
textchat_so.addEventListener(SyncEvent.SYNC, syncEventHandler);
textchat_so.connect(nc);
}
function connectSharedObjectRes(soName:String)
{
connectSharedObject(soName);
}
function initSharedObject(soName:String)
{
// initialize the shared object server side
nc.call("initSharedObject", new Responder(connectSharedObjectRes), soName);
}
// Add new messages to the chat box by calling the server side function sendMessage
// Additional properties can be added to the chatMessage object if needed.
// They will be passed through the system to the shared object by the server
function addMessage(msg:String)
{
var chatMessage:Object = new Object();
chatMessage.message = msg;
chatMessage.time = new Date();
chatMessage.user = MovieClip(root).userName;
trace("sendMessage: "+formatMessage(chatMessage));
nc.call("addMessage", null, chatSharedObjectName, chatMessage);
}
doConnect();