hello! I'm trying to do a chat without remote components, the problem is I'can't see the usernames memorized in a remote SharedObject. this is the code:
/////////////////////////////////////////////////////////////////
_root.idchat=0;
_root.utente1 = "";
_root.utente2 = "";
chat_txt.text="ciao";
usersonline="";
//rileva utenti
att="niente";
var qualiutenti:LoadVars = new LoadVars();
qualiutenti.onLoad = function(success){
att="vediamo";
if(success){
_root.utente1 = qualiutenti.utentechat;
_root.utente2 = qualiutenti.utentechat2;
_root.idchat=qualiutenti.idchatpriv;
user_txt.text= _root.utente1;
} else {
att = "non va";
}
};
qualiutenti.sendAndLoad("chat.php",qualiutenti,"POST")
////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////
function clicked(){
// Create a connection Object
client_nc = new NetConnection();
// Connect to the application
client_nc.connect("rtmp:/chatapp", user_txt.text);
users_so = SharedObject.getRemote("users_so", client_nc.uri, true);
// connetto lo SharedObject al Flash Communication Server
users_so.connect(client_nc);
if (users_so.connect(client_nc)) {
adv_txt.text="Connection object and URIs are OK. Wait for first onSync.";
}else {
adv_txt.text="Can't connect - check URIs and the NetConnection object.";
}
users_so.onSync = function() {
// controlla nel debugger i valori assunti dalle proprietà
//test = userList
for ( var i in users_so.data ) {
//_root.peopleonline.removeAll();
if ( users_so.data[i] != null ) {
traccia += users_so.data[i]
//_root.peopleonline.addItem(users_so.data[i]);
//usersonline=usersonline+users_so.data[i];
//chat_txt.text=chat_txt.text+users_so.data[i];
}
}
}
chat_txt.text=traccia;
}
connectbutton.addEventListener("click", clicked);
chat_txt.text=traccia;
(this dynamic text is empty efter the click on the connect button,
I'can see:
adv_txt.text="Connection object and URIs are OK. Wait for first onSync.";
and this is the serverside code:
application.onAppStart = function()
{
// recupero lo shared object 'users_so'
application.users_so = SharedObject.get("users_so", true);
// inizializzo l'history
application.history = "";
// inizializzo la user ID
application.nextId = 0;
}
application.onConnect = function(newClient, name)
{
// nuovo nome del client è uguale allo user inserito nel campo
newClient.name = name;
// creo un id univoco per l'utente incrementando l'application.nextId
newClient.id = "u" + application.nextId++;
// aggiorno lo shared object 'users_so' con il nome utente
application.users_so.setProperty(newClient.name, name);
// accetto la connessione dell'utente
application.acceptConnection(newClient);
// chaimo la funzione 'setHistory,' e le
// passo la history iniziale
newClient.call("setHistory", null, application.history);
// il client utilizza quesat funzione per recuperare i dati
// dal server che a sua volta li distribuisce agli altri client
newClient.msgFromClient = function(msg, time) {
msg = this.name + " [" + time + "] " + ": " + msg + "\n";
application.history += msg;
application.users_so.send("msgFromSrvr", msg);
}
}
application.onDisconnect = function(client)
{
trace("disconnesso: " + client.name);
application.users_so.setProperty(client.name, null);
}
can you help me to find the mistake??
(sorry for my english)