MACROMEDIA FLASH COMMUNICATION SERVER MX-SERVER-SIDE COMMUNICATION ACTIONSCRIPT DICTIONARY Specifikace Strana 157

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 369
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 156
Application Development Tips and Tricks 79
Getting the stream time length in ActionScript
If you are buffering your streams, you can use the
NetStream.bufferLength property to get the
number of seconds currently in the buffer. Sometimes, however, you may want to get the total
length of a stream; in this case, the Flash Player doesnt know the length of the stream, but the
server does. The server has a
Stream.length property that the client can request through a
message to the server.
You could write client-side ActionScript such as the following to request the stream length:
function getInfo()
{
nc.call("sendInfo", new MyResultSetName(), myStream);
}
function MyResultSetName()
{
this.onResult = function(retVal)
{
_root.streamlength = retVal;
};
this.onStatus = function(info)
{
trace("Level: " + info.level + " Code: " + info.code);
// process error object
};
}
Then, in the corresponding server-side ActionScript, you would write the following in the
main.asc file:
application.onAppStart = function()
{
trace("::: Application has started :::");
}
application.onConnect = function(client)
{
application.acceptConnection(client);
// Add methods
client.prototype.sendInfo = function(name) {
var slen = Stream.length(name);
trace("slen: " + slen);
return slen;
};
}
Zobrazit stránku 156
1 2 ... 152 153 154 155 156 157 158 159 160 161 162 ... 368 369

Komentáře k této Příručce

Žádné komentáře