MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Spécifications Page 122

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 369
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 121
Chapter 3 44
9 In the same doConnect function, create the onSync method to handle the change in users.
// When the list of users_so is updated, refresh the
// People list box.
users_so.onSync = function(userList) {
_root.People.removeAll();
for ( var i in users_so.data) {
if (users_so.data[i] != null) {
_root.People.addItem(users_so.data[i]);
}
}
// Sort alphabetically, because order returned
// is not guaranteed to be consistent.
_root.People.sortItemsBy("label", "ASC");
}
10
Provide a callback function to be called by the server.
// Update the shared object with the message.
users_so.msgFromSrvr = function(msg) {
_root.History.text += msg;
_root.History.scroll = _root.History.maxscroll;
historyScroll.setScrollTarget(history);
historyScroll.setScrollPosition(_root.History.maxscroll);
}
}
11
If the label on the Connect button is Disconnect, then close the connection and reset the
buttons.
else if (Connect_btn.getLabel() == "Disconnect") {
// Close connection
_root.client_nc.close();
// Don’t allow the user to send when not connected
_root.Send_btn.setEnabled(false);
// Rest button label
Connect_btn.setLabel("Connect");
}
} // doConnect function ends here
12
Create an event handler for when the user selects Send. In this function, if there’s any text in
the Message input text box, call the server function,
msgFromClient, and pass it the
Message.text text.
// Send the message text by calling the server message function
function doSend() {
// If there’s message text, pass it to the server function msgFromClient
if (length(_root.Message.text) > 0) {
_root.client_nc.call("msgFromClient", null, _root.Message.text);
}
// Clear the message text
_root.Message.text = "";
}
Vue de la page 121
1 2 ... 117 118 119 120 121 122 123 124 125 126 127 ... 368 369

Commentaires sur ces manuels

Pas de commentaire