All pastes #107494 Raw Edit

Something

public text v1 · immutable
#107494 ·published 2006-07-31 01:27 UTC
rendered paste body
History.leading=5;
chatz="0";
grid.rowHeight = 19;
_root.create_room_movie._visible = false;
adminbut._visible=false;
Message.restrict = " a-z0-9:,';!?()éèê";
Message.maxChars = 95.750000;
me.text = UserName;
private_bg._visible=false;
myvideo._visible=false;
var LastDataGridSelected:String = "";
var gridlistener:Object = new Object();

gridlistener.change = function(eventObject) {
if (grid.selectedItem.label != _root.nick) {
LastDataGridSelected = _root.nick;
if (LastDataGridSelected != "") user_nc.call("whowatch", null, LastDataGridSelected, false);
}

        _root.nick = grid.selectedItem.label;
		_root.opipp = grid.selectedItem.data.ip;
		video.close();
		video.clear();
		History._x = 413; 
		History._y = 161;
		History.setSize(340, 256);
        who.text = grid.selectedItem.label;
		private_bg.private_name.html=true;
		private_bg.private_name.htmlText="Private Message <b>"+ _root.nick+"</b>";
		private_bg._visible=true;
		adminbut.opname.text=_root.nick;
		adminbut.opip.text= _root.opipp;
		History.vPosition = History.maxVPosition;
		user_nc.call("whowatch", null, _root.nick, true);
		//Play Stream
		In_ns = new NetStream(user_nc);
		video.attachVideo(In_ns);
		video.attachAudio(In_ns);
		In_ns.play(nick);
} 


if (In_ns.play = null)
{
video.clear();
}

if (_root.log_ok="1") {
init();
manageSO();
trace("log");
user_nc.call("settopic", null, msg);
}

function init() {
	InitSO();
	_root.log_ok="0";
	grid.empty();
	trace("iniini");
	login_btn.enabled = false;
	login_btn._alpha = 50;
	login_txt.enabled = false;
	ns = new NetStream(user_nc);
    mycam = Camera.get();
    mycam.setQuality(8192, 0);
    mycam.setMode(173, 142, 8);
    mycam.setKeyFrameInterval(30);
	mymic = Microphone.get();
    mymic.setGain(38);
    mymic.setRate(8);
	ns.attachVideo(mycam);
	ns.attachAudio(mymic);
	myvideo.attachVideo(mycam);
	myvideo._visible=true;
	mycam.owner = this;
	if (mycam != null) {
		mycam.onStatus = function(infos) {
			if (infos.code == "Camera.Unmuted") {
				this.owner.cameraOk();
			} else if (infos.code == "Camera.Muted") {
				this.owner.cameraNo();
			}
		};
		if (mycam.muted == false) {
			cameraOk();
		} else if (mycam.muted == true) {
			cameraNo();
		}
	} else if (mycam == null) {
		cameraNo();
	}
}


function cameraOk() {
	trace("camera allowed");
	ns.publish(UserName);
	statut = true;
	statut_txt.text = "";
	user_nc.call("getStatut", null, statut);
}

function cameraNo() {
	trace("cam not allowed");
	ns.publish(false);
	myvideo.clear();
	statut = false;
	user_nc.call("getStatut", null, statut);
}

user_nc.newClientForAll = function(allClients) {
	for (var i in allClients) {
		afficheName(allClients[i]);
	}
};

user_nc.newClient = function(client) {
	afficheName(client);
	user_nc.call("whowatch", null, _root.nick, true);
};

user_nc.initList = function(allClients) {
	grid.removeAll();
	for (var i in allClients) {
		afficheName(allClients[i]);
	}
};
function afficheName(client) {
var stat = getStat(client);
o = {label:client.UserName, data:client, data:client.ip, monIcon:stat};
grid.iconField = "monIcon";
grid.addItem(o);
var count = grid.length;
counter.text = count;
grid.sortItemsBy("id", "DESC");
}

user_nc.whowatch = function(nick, watching){
for (var I:Number=0; I<grid.length; I++){
if (grid.getItemAt(I).label == nick){
if (watching == true){
if (grid.getItemAt(I).monIcon=="male_cam"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"who_cam_male"});
}else if (grid.getItemAt(I).monIcon=="female_cam"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"who_cam_female"});
}else if (grid.getItemAt(I).monIcon=="male"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"who_male"});
}
else if (grid.getItemAt(I).monIcon=="female"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"who_female"});
}
} else {
if (grid.getItemAt(I).monIcon == "who_cam_male"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"male_cam"});
}
else if (grid.getItemAt(I).monIcon == "who_cam_female"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"female_cam"});
}else if (grid.getItemAt(I).monIcon=="who_male"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"male"});
}else if (grid.getItemAt(I).monIcon=="who_female"){
grid.replaceItemAt (I, {label:nick, data:nick, monIcon:"female"});
}
}
}
}
} 

function getStat(client):String {
	if (client.statut) {
		if (client.sex=="male") {
		return "male_cam"; 
		} else if (client.sex=="female") { 
		return "female_cam";
	} } else {
		if (client.sex=="male") {
		return "male"; 
		} else if (client.sex=="female") { 
		return "female";
	}
		return;
	}
} 

function Xcolor(color) {
Colors_drop=color;
trace(Colors_drop);
}

doSend.onPress = function() {
if (length(Message.text)>0) {
		var tts:String = Message.text;
		tts = '<font face="Tahoma" size="11" color="'+_root.Colors_drop+'">'+tts+"</font>";
		user_nc.call("msgFromClient", null, tts);
	}
	Message.text = "";
} 

user_nc.kicked = function() { 
ns.close();
user_nc.close();
gotoandstop(4);
}

user_nc.Banned = function (){
ns.close();
user_nc.close();  
gotoAndStop(5);
};

String.prototype.replace = function(original,destination) { 
return this.split(original).join(destination); 
}

function manageSO()
{
    users_so = SharedObject.getRemote("users_so",  _root.user_nc.uri, false);
    users_so.onSync = function (userList)
    {
    };
    users_so.connect(user_nc);
    users_so.msgFromSrvr = function(msg)
    {
     History.text += msg.replace("ivideochat","").replace("msn","").replace("chatvideo","").replace(".com","").replace(".net","").replace(".ca","").replace("mirc","").replace("hotmail","").replace("www","").replace("http","").replace("m s n","").replace("email","").replace("e m a i l","").replace("ms n","").replace("m sn","");
     History.vPosition = History.maxVPosition;
    };
} 

user_nc.privateMsgClient = function(msg) { 
History.text += msg.replace("ivideochat","").replace("msn","").replace("chatvideo","").replace(".com","").replace(".net","").replace(".ca","").replace("mirc","").replace("hotmail","").replace("www","").replace("http","").replace("m s n","").replace("email","").replace("e m a i l","").replace("ms n","").replace("m sn","");
History.vPosition = History.maxVPosition;
adminbut._visible=false;
op_btn._visible=true;
};

adminbut.kick_pb.onRelease = function (){
var theusername = grid.selectedItem.label;
user_nc.call("kickUser", null, theusername);
adminbut._visible=false;
op_btn._visible=true;
};

adminbut.ban_ip.onRelease = function (theip,duration){
var theip = grid.selectedItem.data.ip;
trace("theip est: "+theip);
user_nc.call("banuser", null, theip, adminbut.radioGroup.selection.data);
}
function InitSO() {
	trace("initso");
list_so = SharedObject.getRemote("list_so", _root.user_nc.uri, false);
list_so.connect(_root.user_nc);
list_so.onSync = function(roomList) {
var nr:Number = 0;
_root.Rooms.removeAll();
for (var i in list_so.data) {

if (list_so.data[i].room != null) {
_root.Rooms.addItem({users:list_so.data[i].users, name:list_so.data[i].room, label:list_so.data[i].room+" ("+list_so.data[i].users+") ", data:list_so.data[i].room, id:i, users:list_so.data[i].users});
}
}
len = _root.Rooms.length;
_root.Rooms.sortItemsBy("id", "ASC");
for (var i = 0; i<=len; i++) {
if (_root.Rooms.getItemAt(i).data == "Lobby") {
itm_label = _root.Rooms.getItemAt(i).label;
_root.Rooms.removeItemAt(i);
_root.Rooms.addItemAt(0, {label:itm_label, data:"Lobby", id:"r1"});
			}
		}
}
}

user_nc.set_topic = function(msg) {
	History.text=msg;
	msgServer.text=msg;
	History.vPosition = History.maxVPosition;
}

user_nc.set_joined = function(msg) {
	History.text=msg;
	msgServer.text=msg;
	History.vPosition = History.maxVPosition;
}
function closeStreams() {
ns.close();
}

Rooms.change = function(eventObj) {
	if (_root.Rooms.selectedItem.users != 0) {
		_root.Delete_btn.enabled = false;
	} else {
		_root.Delete_btn.enabled = true;
	}
	if (_root.Rooms.selectedItem.id == "r1") {
    _root.CRID = _root.Rooms.selectedItem.id;
	_root.crname=_root.Rooms.selectedItem.name;
	_root.doRoomConnect(_root.CRID)	;
	_root.grid.removeAll();
	_root.iniSo();
     } else {
	_root.CRID = _root.Rooms.selectedItem.id;
	_root.crname=_root.Rooms.selectedItem.name;
	_root.doRoomConnect(_root.CRID)	;
	_root.grid.removeAll();
	_root.iniSo();
	}
};

function doDisConnect()
{
ns.close();
user_nc.close();
}

Rooms.addEventListener("change", Rooms);

grid.setStyle("borderStyle", "solid");
grid.setStyle("color", "0x626262");
grid.setStyle("backgroundColor", "0xF7F7F7");
grid.setStyle("fontSize", "11");
grid.setStyle("fontFamily", "Tahoma");
grid.setStyle("themeColor", "0xEEF8CD");
grid.setStyle("selectionColor", "0xD3F174");
grid.setStyle("selectionDisableColor", "0xFFFFFF");
grid.addEventListener("change", gridlistener);

var usernameListener = new Object();
usernameListener.owner = this;
usernameListener.onKeyDown = function ()
{
if (this.owner.Message.MessagehasFocus && Key.isDown(Key.ENTER)){
this.owner.doSend.onPress();
Key.removeListener(usernameListener);
inter = setInterval(function (){
Key.addListener(usernameListener);
clearInterval(inter);
}, 2000);
} 
}; 

focusManager.setFocus("Message");
Message.MessagehasFocus = false;
Key.addListener(usernameListener);

Message.onKillFocus = function ()
{
this.MessagehasFocus = false;
};
Message.onSetFocus = function ()
{
this.MessagehasFocus = true;
};



stop();