
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
25
}
The following example is client-side ActionScript 3.0 code:
var theConnection:NetConnection;
var theConnection2:NetConnection;
var client:Object = new Object();
function init():void{
connect_button.label = "Connect";
disconnect_button.label = "Disconnect";
connect_button.addEventListener(MouseEvent.CLICK, buttonHandler);
disconnect_button.addEventListener(MouseEvent.CLICK, buttonHandler);
}
function buttonHandler(event:MouseEvent){
switch (event.target){
case connect_button :
doConnect();
break;
case disconnect_button :
disConnect();
break;
}
}
function doConnect(){
makeConnection(theURI.text);
}
function disConnect(){
theConnection.close();
}to
function makeConnection(uri:String){
if (theConnection){
theConnection.close();
}
theConnection = new NetConnection();
theConnection.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
theConnection.client = client;
theConnection.connect(uri);
}
function makeConnection2(uri:String){
if (theConnection2){
theConnection2.close();
}
theConnection2 = new NetConnection();
theConnection2.addEventListener(NetStatusEvent.NET_STATUS, netStatusHandler);
theConnection2.client = client;
theConnection2.connect(uri);
}
function netStatusHandler(event:NetStatusEvent):void{
//Check the Redirect code and make connection to redirect URI if appropriate.
try{
if (event.info.ex.code == 302){
var redirectURI:String;
redirectURI = event.info.ex.redirect;
Commentaires sur ces manuels