Hey all. I have a flash video recorder set up to do some encoding, and based
on the users input to where they want the connection stream to for a live or
recorded, or both, it should the go to a 'subscriber' frame and then connect
the camera object, etc. I have successfully done this, however, I can not for
the life of me figure out why the Login button (handled by the appLogin
function) has to be clicked TWICE before moving to the 'subscriber' frame. Any
fresh eyes that want to look at this actionscript and give me the AH HA factor
would be great!
Here's the source:
// Declare Timeline Variables
var statuslive:Boolean = false;
var statusrecorded:Boolean = false;
var connection:String;
var connection2:String;
//
// Local Application Function Handlers
//
appLogin = function () {
// Login Button was clicked, make the connections with the server
// Check to see what connection strings were provided
if (connection_txt.text) {
myConnection_nc = new NetConnection();
connectionLight_mc.connect(myConnection_nc);
connection = "rtmp://"+connection_txt.text+"/videoPrototypeApp/myInstance";
myConnection_nc.connect(connection);
// What to do if able to, or not able to connect
myConnection_nc.onStatus = function(info) {
trace("LEVEL: "+info.level+" CODE: "+info.code);
if (info.code == "NetConnection.Connect.Success") {
statuslive = true;
}
if (info.code == "NetConnection.Connect.Failed" || info.code ==
"NetConnection.Connect.Rejected") {
invalid_txt.visible = true;
invalid_txt.text = "Unable to establish Connection, will try address for a
recorded stream.";
statuslive = false;
}
};
}
if (connection2_txt.text) {
myConnection2_nc = new NetConnection();
connectionLight2_mc.connect(myConnection2_nc);
connection2 = "rtmp://"+connection2_txt.text+"/videoPrototypeApp/myInstance";
myConnection2_nc.connect(connection2);
myConnection2_nc.onStatus = function(info) {
trace("LEVEL: "+info.level+" CODE: "+info.code);
if (info.code == "NetConnection.Connect.Success") {
statusrecorded = true;
}
if (info.code == "NetConnection.Connect.Failed" || info.code ==
"NetConnection.Connect.Rejected") {
invalid_txt.visible = true;
invalid_txt.text = "Unable to establish Connection, will connect and
stream locally.";
connection2 = "rtmp://localhost/videoPrototypeApp/myInstance";
myConnection2_nc.connect(connection2);
myConnection2_nc.onStatus = function(info) {
trace("LEVEL: "+info.level+" CODE: "+info.code);
if (info.code == "NetConnection.Connect.Success") {
statusrecorded = true;
}
if (info.code == "NetConnection.Connect.Failed" || info.code ==
"NetConnection.Connect.Rejected") {
invalid_txt.visible = true;
invalid_txt.text = "Unable to establish any Connection: localhost Flash
Server does not exist.";
statusrecorded = false;
}
};
}
};
}
if(statusrecorded || statuslive){
gotoAndPlay("subscriber");
}
};
appClose = function () {
if (myConnection_nc.isConnected) {
myConnection_nc.close();
}
if (myConnection2_nc.isConnected) {
myConnection2_nc.close();
}
_root.gotoAndStop(1);
logout_pb.setEnabled(false);
};
stop();