Advertisement
Guest User

Parse error

a guest
May 24th, 2015
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package
  2. {
  3.     import fl.events.*;
  4.     import flash.media.SoundTransform;
  5.     import flash.media.SoundMixer;
  6.     import flash.display.*;
  7.     import flash.events.*;
  8.     import flash.net.*;
  9.     import flash.utils.*;
  10.     import flash.text.*;
  11.     import flash.external.ExternalInterface;
  12.     import flash.system.Security;
  13.     import flash.events.IOErrorEvent;
  14.     import flash.net.SharedObject;
  15.     import flash.system.LoaderContext;
  16.  
  17.     public class Chat extends MovieClip
  18.     {
  19.         private var banCookie:SharedObject = SharedObject.getLocal("chat22");
  20.         private var messageArray:Array = new Array();
  21.         private var chatBoxMessageArray:Array = new Array();
  22.         private var usersTimedOutArray:Array = new Array();
  23.         private var adminCode:String;
  24.         private var country:String;
  25.         private var city:String;
  26.         private var adminCodeBox:adminCode_mc = new adminCode_mc();
  27.         private var initialServerDate:Number = 1;
  28.         private var firstServerTime:String;
  29.         private var currentDate:Date = new Date();
  30.         private var maximumMessages:Number = 4;
  31.         private var message_str:String;
  32.         private var userlistButtonArray:Array = new Array();
  33.        
  34.         private var privateChatBox:privateMessage_mc;
  35.         private var chatBoxesArray:Array = new Array();
  36.         private var selectedChatBox:MovieClip;
  37.        
  38.         private var privateMessageBox:privateMessage_mc = new privateMessage_mc();
  39.         private var privateMessageSender:String;
  40.        
  41.         private var chatTextColor:String = "#FFFFFF";
  42.         private var chatLinkColor:String = "#FF8500";
  43.         private var adminTextColor:String = "#FFD500";
  44.        
  45.         private var chatXML:XML;
  46.         private var userXML:XML;
  47.         private var archiveXmlLoader:URLLoader = new URLLoader();
  48.         private var chatXmlLoader:URLLoader = new URLLoader();
  49.         private var userXmlLoader:URLLoader = new URLLoader();
  50.         private var updateTimerChat:Timer = new Timer(3000);
  51.         private var updateTimerUserlist:Timer = new Timer(5000);
  52.        
  53.         private var floodingTimer:Timer = new Timer(5000);
  54.         private var floodingCounter:Number = 0;
  55.         private var mutedCounter:Number = 0;
  56.         private var mutedAmount:Number = 25;
  57.         private var userNotFoundCounter:Number = 0;
  58.         private var currentUserListed:Boolean = true;
  59.         private var vars:URLVariables;
  60.         private var phpRequest:URLRequest;
  61.         private var phpLoader:URLLoader;
  62.         private var phpResultVars:URLVariables;
  63.         private var chatProcessUrl:String = "xml_chatprocess.php";
  64.         private var userProcessUrl:String = "xml_userprocess.php";
  65.         private var chatFunctionsUrl:String = "chat_functions.php" + "?nocache=" + new Date().getTime();
  66.  
  67.         private var timeoutArray:Array = new Array();
  68.         public var userEnter:String;
  69.         private var currentUser:String = "notConnected";
  70.         private var currentMessages:Number;
  71.         private var lastMessageTime:Number;
  72.         private var previousTimeStamp:String;
  73.         private var injectingHistory:Boolean = false;
  74.         private var chatMessage:String;
  75.        
  76.         private var sound_camera:CameraSound = new CameraSound();
  77.         private var sound_newUser:NewUserSound = new NewUserSound();
  78.         private var sound_newMessage:NewMessageSound = new NewMessageSound();
  79.         private var sound_exitUser:ExitUserSound = new ExitUserSound();
  80.         private var sounds:Boolean = true;
  81.         private var sTransform:SoundTransform = new SoundTransform(1,0);
  82.        
  83.         private var _bitmap:Bitmap;
  84.         private var messageDuplicateExists:Boolean = false;
  85.        
  86.         private var adminActionOnUser:String;
  87.         private var ignoredUsers:Array = new Array();
  88.        
  89.         private var camController:CamController;
  90.         private var camSessionID:String;
  91.         private var camSessionToken:String;
  92.         private var camSessionAPI:String;
  93.        
  94.         private var privateBoxesScrollTimer:Timer = new Timer(500);
  95.        
  96.         /*Initiates the chat on load*/
  97.         public function Chat()
  98.         {              
  99.             stage.stageFocusRect = false;
  100.             stage.scaleMode = StageScaleMode.NO_SCALE;
  101.             stage.align = StageAlign.TOP_LEFT;
  102.            
  103.             trace("CAMCOM Chat 5.0 Engine");
  104.             trace("----------------------------------------------------------");
  105.             trace("Created by Sven Kohn");
  106.             trace("(C) 2009 - 2014 by Mindprobe - www.mind-probe.com");
  107.             trace("----------------------------------------------------------");
  108.             trace("-> Initializing chat");
  109.             trace("-> Awaiting user login...");
  110.                    
  111.             updateTimerChat.addEventListener(TimerEvent.TIMER, updateChatData); // Chat window data refresh Timer
  112.             updateTimerUserlist.addEventListener(TimerEvent.TIMER, updateUserListData); // Userlist window data refresh Timer
  113.             floodingTimer.addEventListener(TimerEvent.TIMER, floodingCheck); // Flooding check Timer
  114.            
  115.             updateChatData(null);
  116.             updateUserListData(null);
  117.            
  118.             updateTimerChat.start();
  119.             updateTimerUserlist.start();
  120.             floodingTimer.start();
  121.            
  122.             send_btn.tabEnabled = false;
  123.             send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  124.            
  125.             input_txt.text = "";
  126.             input_txt.tabEnabled = false;
  127.             input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  128.            
  129.             logout_btn.tabEnabled = false;
  130.             logout_btn.addEventListener(MouseEvent.CLICK, onLogout);
  131.            
  132.             muteButton_mc.tabEnabled = false;
  133.             muteButton_mc.buttonMode = true;
  134.             muteButton_mc.addEventListener(MouseEvent.CLICK, onMuteButtonClick);
  135.            
  136.             roomButton_btn.tabEnabled = false;
  137.             roomButton_btn.addEventListener(MouseEvent.CLICK, onChangeRoomButtonClick);
  138.            
  139.             function onMuteButtonClick(event:MouseEvent):void
  140.             {      
  141.                 if(event.currentTarget.currentLabel == "on")
  142.                 {
  143.                     event.currentTarget.gotoAndStop("off");
  144.                     sTransform.volume = 0;
  145.                     SoundMixer.soundTransform = sTransform;
  146.                 }
  147.                 else if(event.currentTarget.currentLabel == "off")
  148.                 {
  149.                     event.currentTarget.gotoAndStop("on");
  150.                     sTransform.volume = 1;
  151.                     SoundMixer.soundTransform = sTransform;
  152.                 }
  153.             }
  154.            
  155.             function onChangeRoomButtonClick(event:MouseEvent):void
  156.             {      
  157.                 sa.addText("<font color='" + chatTextColor + "'><b><font color='" + chatLinkColor + "'>[ Chat Rooms List ] -----------------------------------------------------------------------------------------</b></font></font>");
  158.                 sa.addText("<font color='" + chatTextColor + "'>No chat rooms added to list</font>");
  159.                
  160.                 /*sa.addText("<font color='" + chatTextColor + "'><a href='http://www.photonchat.com/index.php' target='_blank'><u><font color='" + chatLinkColor + "'>#Lobby</font></u></a>Please use this room for general chat only </font>");
  161.                 sa.addText("<font color='" + chatTextColor + "'><a href='http://www.facebook.com/apps/application.php?id=222876551063393' target='_blank'><u><font color='" + chatLinkColor + "'># Facebook Chat Room</font></u></a> - Photon Chat 5 running on a Facebook page</font>");
  162.                 sa.addText("<font color='" + chatTextColor + "'><a href='http://www.photonchat.com/skins/skin1/index.html' target='_blank'><u><font color='" + chatLinkColor + "'># Chat Room Skin 1</font></u></a> - Google / Facebook look-a-like chat room</font>");
  163.                 sa.addText("<font color='" + chatTextColor + "'><a href='http://www.photonchat.com/skins/skin2/index.html' target='_blank'><u><font color='" + chatLinkColor + "'># Chat Room Skin 2</font></u></a> - Chat room with custom made design</font>");
  164.                 sa.addText("<font color='" + chatTextColor + "'><a href='http://www.photonchat.com/socialsex/' target='_blank'><u><font color='" + chatLinkColor + "'># Chat Room Skin 3</font></u></a> - Chat room with custom made design</font>");
  165.                 sa.addText("<font color='" + chatTextColor + "'><a href='http://www.photonchat.com/flashavatarchat/index.html' target='_blank'><u><font color='" + chatLinkColor + "'># Virtual World Chat</font></u></a> - Fly around and chat with people in a virtual world</font>");*/
  166.  
  167.                 chatMessage = "";
  168.             }
  169.            
  170.             /*Timer updates the message and userlist window*/
  171.             function updateChatData(event:TimerEvent):void
  172.             {
  173.                 chatXmlLoader.load(new URLRequest("chathistory.xml" + "?nocache=" + new Date().getTime()));
  174.                 chatXmlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  175.                 chatXmlLoader.addEventListener(Event.COMPLETE, processChatXML);
  176.             }
  177.  
  178.             function updateUserListData(event:TimerEvent):void
  179.             {
  180.                 userXmlLoader.load(new URLRequest("userlist.xml" + "?nocache=" + new Date().getTime()));
  181.                 userXmlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  182.                 userXmlLoader.addEventListener(Event.COMPLETE, processUserXML);
  183.             }
  184.            
  185.             function floodingCheck(event:TimerEvent):void
  186.             {              
  187.                 if(floodingCounter >= 3)
  188.                 {
  189.                     sa.addText("<font color='" + chatLinkColor + "'>>> <b>[Flood Control]</b> You are blocked for " + mutedAmount + " seconds</font>");
  190.                     input_txt.text = "";
  191.                     send_btn.removeEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  192.                     input_txt.removeEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  193.                     mutedCounter++;
  194.                     mutedAmount -= 5;
  195.                    
  196.                     if(mutedCounter >= 6)
  197.                     {
  198.                         sa.addText("<font color='" + chatLinkColor + "'>>> <b>[Flood Control]</b> You are not blocked anymore</font>");
  199.                         mutedCounter = 0;
  200.                         mutedAmount = 25;
  201.                         send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  202.                         input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  203.                     }
  204.                 }
  205.  
  206.                 if(mutedCounter <= 0)
  207.                 {
  208.                     floodingCounter = 0;
  209.                 }
  210.             }
  211.                        
  212.            
  213. // FUNCTION processChatXML - Retrieves new message data from XML, apply filters, add to message array and play sound effects
  214. // ***************************************************************************************************************************************
  215. // ***************************************************************************************************************************************
  216. // *************************************************************************************************************************************** 
  217.     var test:String;       
  218.             function processChatXML(event:Event):void
  219.             {
  220.                 try
  221.                 {
  222.                     chatXML = new XML(event.target.data);
  223.                    
  224.                     var soundToPlay:String = "none";
  225.                     messageArray = new Array();
  226.                    
  227.                     if(chatXML.*.length() > 0)
  228.                     {
  229.                         for (var i:int = 0; i < chatXML.*.length(); i++)
  230.                         {
  231.                             messageArray.push({timestamp:chatXML.entry.timestamp[i], username:chatXML.entry.name[i], chatmessage:String(chatXML.entry.message[i]), messagetime:Number(chatXML.entry.messagetime[i])});
  232.                         }
  233.  
  234.                         if(chatBoxMessageArray.length == 0)
  235.                         {
  236.                             chatBoxMessageArray = messageArray;
  237.                            
  238.                             for (var a:int = 0; a < chatBoxMessageArray.length; a++)
  239.                             {
  240.                                 if(chatBoxMessageArray[a].chatmessage.substr(0,8) == "/private" &&
  241.                                    chatBoxMessageArray[a].chatmessage.substr(9,currentUser.length) != currentUser)
  242.                                 {
  243.                                     // skip message that are private from other users
  244.                                 }
  245.                                 else if(chatBoxMessageArray[a].chatmessage.substr(0,6) == "Leaves" ||
  246.                                         chatBoxMessageArray[a].chatmessage.substr(0,12) == "is no longer")
  247.                                 {
  248.                                     // skip logout and timeout messages                            
  249.                                 }
  250.                                 else
  251.                                 {
  252.                                     var pattern:RegExp = /@/i;
  253.                                     if(chatBoxMessageArray[a].username.search(pattern) != -1)
  254.                                     {
  255.                                         sa.addText("<font color='" + adminTextColor + "'>" + "<b>" + String(chatBoxMessageArray[a].username) + ": " + "</b>" + String(chatBoxMessageArray[a].chatmessage) + "</font>");
  256.                                     }
  257.                                     else
  258.                                     {
  259.                                         sa.addText("<font color='" + chatTextColor + "'>" + "<b>" + String(chatBoxMessageArray[a].username) + ": " + "</b>" + String(chatBoxMessageArray[a].chatmessage) + "</font>");
  260.                                     }
  261.  
  262.                                     previousTimeStamp = String(chatBoxMessageArray[a].timestamp);
  263.                                 }
  264.                             }
  265.                         }              
  266.                         else
  267.                         {
  268.                             // each message in the XML is compared to each message in the chatBox Array
  269.                             for (var h:int = 0; h < messageArray.length; h++)
  270.                             {
  271.                                 for (var b:int = 0; b < chatBoxMessageArray.length; b++)
  272.                                 {  
  273.                                     if(messageArray[h].username == chatBoxMessageArray[b].username &&
  274.                                        messageArray[h].chatmessage == chatBoxMessageArray[b].chatmessage &&
  275.                                        messageArray[h].messagetime == chatBoxMessageArray[b].messagetime ||
  276.                                        messageArray[h].username == chatBoxMessageArray[b].username &&
  277.                                        messageArray[h].chatmessage == chatBoxMessageArray[b].chatmessage &&
  278.                                        "1" == chatBoxMessageArray[b].messagetime)
  279.                                     {
  280.                                         messageDuplicateExists = true;
  281.                                         break;
  282.                                     }
  283.                                     else
  284.                                     {
  285.                                         messageDuplicateExists = false;
  286.                                     }
  287.                                 }
  288.    
  289.                                 if(messageDuplicateExists == false)
  290.                                 {
  291.                                     //Add new message to chatbox and chatBoxMessageArray
  292.                                     chatBoxMessageArray.push({timestamp:messageArray[h].timestamp, username:messageArray[h].username, chatmessage:messageArray[h].chatmessage, messagetime:messageArray[h].messagetime});
  293.                                     previousTimeStamp = String(messageArray[h].timestamp);
  294.                                    
  295.                                     if(messageArray[h].chatmessage.substr(0,8) == "/private" &&
  296.                                             messageArray[h].chatmessage.substr(9,currentUser.length) == currentUser)
  297.                                     {
  298.                                        
  299.                                     }
  300.                                     else if(messageArray[h].chatmessage.substr(0,8) == "/private" &&
  301.                                        messageArray[h].chatmessage.substr(9,currentUser.length) != currentUser)
  302.                                     {
  303.                                         trace("-> Hidden private message from other user");
  304.                                     }
  305.                                     else
  306.                                     {
  307.                                         if(ignoredUsers.length > 0)
  308.                                         {
  309.                                             var userIgnored:Boolean = false;
  310.                                        
  311.                                             for (var sw:int = 0; sw < ignoredUsers.length; sw++)
  312.                                             {
  313.                                                 if(ignoredUsers[sw] == messageArray[h].username)
  314.                                                 {
  315.                                                     userIgnored = true;
  316.                                                     break;
  317.                                                 }
  318.                                                 else
  319.                                                 {
  320.                                                     userIgnored = false;
  321.                                                 }
  322.                                             }
  323.                                            
  324.                                             if(userIgnored == false)
  325.                                             {
  326.                                                 var alreadyTimedOut:Boolean = false;
  327.                                                
  328.                                                 if(messageArray[h].chatmessage.substr(0,12) == "is no longer")
  329.                                                 {
  330.                                                     for (var mh:int = 0; mh < usersTimedOutArray.length; mh++)
  331.                                                     {
  332.                                                         if(usersTimedOutArray[mh] != messageArray[h].username)
  333.                                                         {
  334.                                                             alreadyTimedOut = false;
  335.                                                         }
  336.                                                         else
  337.                                                         {
  338.                                                             alreadyTimedOut = true;
  339.                                                             break;
  340.                                                         }
  341.                                                     }
  342.                                                    
  343.                                                     if(alreadyTimedOut == false)
  344.                                                     {
  345.                                                         pattern = /@/i;
  346.                                                         if(messageArray[h].username.search(pattern) != -1)
  347.                                                         {
  348.                                                             sa.addText("<font color='" + adminTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  349.                                                         }
  350.                                                         else
  351.                                                         {
  352.                                                             sa.addText("<font color='" + chatTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  353.                                                         }
  354.                                                        
  355.                                                         usersTimedOutArray.push(String(messageArray[h].username));
  356.                                                     }
  357.                                                 }
  358.                                                 else
  359.                                                 {
  360.                                                     pattern = /@/i;
  361.                                                     if(messageArray[h].username.search(pattern) != -1)
  362.                                                     {
  363.                                                         sa.addText("<font color='" + adminTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  364.                                                     }
  365.                                                     else
  366.                                                     {
  367.                                                         sa.addText("<font color='" + chatTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  368.                                                     }
  369.                                                 }
  370.                                                 userIgnored = false;
  371.                                             }
  372.                                         }
  373.                                         else
  374.                                         {                                                                          
  375.                                             alreadyTimedOut = false;
  376.                                                
  377.                                             if(messageArray[h].chatmessage.substr(0,12) == "is no longer")
  378.                                             {
  379.                                                 for (var xd:int = 0; xd < usersTimedOutArray.length; xd++)
  380.                                                 {
  381.                                                     if(usersTimedOutArray[xd] != messageArray[h].username)
  382.                                                     {
  383.                                                         alreadyTimedOut = false;
  384.                                                     }
  385.                                                     else
  386.                                                     {
  387.                                                         alreadyTimedOut = true;
  388.                                                         break;
  389.                                                     }
  390.                                                 }
  391.                                                
  392.                                                 if(alreadyTimedOut == false)
  393.                                                 {
  394.                                                     pattern = /@/i;
  395.                                                     if(messageArray[h].username.search(pattern) != -1)
  396.                                                     {
  397.                                                         sa.addText("<font color='" + adminTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  398.                                                     }
  399.                                                     else
  400.                                                     {
  401.                                                         sa.addText("<font color='" + chatTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  402.                                                     }
  403.                                                    
  404.                                                     usersTimedOutArray.push(String(messageArray[h].username));
  405.                                                 }
  406.                                             }
  407.                                             else
  408.                                             {
  409.                                                 pattern = /@/i;
  410.                                                 if(messageArray[h].username.search(pattern) != -1)
  411.                                                 {
  412.                                                     sa.addText("<font color='" + adminTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  413.                                                 }
  414.                                                 else
  415.                                                 {
  416.                                                     sa.addText("<font color='" + chatTextColor + "'>" + "<b>" + String(messageArray[h].username) + ": " + "</b>" + String(messageArray[h].chatmessage) + "</font>");
  417.                                                 }
  418.                                             }
  419.                                         }
  420.                                     }
  421.                                    
  422.                                     if(chatBoxMessageArray.length >= messageArray.length * 2)
  423.                                     {
  424.                                         chatBoxMessageArray.splice(0,1);
  425.                                     }
  426.                                                                    
  427.                                     if(messageArray[h].chatmessage.substr(0,6) == "Enters")                  
  428.                                     {
  429.                                         soundToPlay = "userEnters";
  430.                                     }
  431.                                     else if(messageArray[h].chatmessage.substr(0,6) == "Leaves" ||
  432.                                             messageArray[h].chatmessage.substr(0,12) == "is no longer")          
  433.                                     {
  434.                                         soundToPlay = "userLeaves";
  435.                                     }
  436.                                     else if(messageArray[h].chatmessage.substr(0,8) == "/private" &&
  437.                                             messageArray[h].chatmessage.substr(9,currentUser.length) == currentUser)
  438.                                     {
  439.                                         if(ignoredUsers.length > 0)
  440.                                         {
  441.                                             userIgnored = false;
  442.                                        
  443.                                             for (var bz:int = 0; bz < ignoredUsers.length; bz++)
  444.                                             {
  445.                                                 if(ignoredUsers[bz] == messageArray[h].username)
  446.                                                 {
  447.                                                     userIgnored = true;
  448.                                                     break;
  449.                                                 }
  450.                                                 else
  451.                                                 {
  452.                                                     userIgnored = false;
  453.                                                 }
  454.                                             }
  455.                                            
  456.                                             if(userIgnored == false)
  457.                                             {
  458.                                                 soundToPlay = "newPrivateMessage";
  459.                                                 userIgnored = false;
  460.                                                
  461.                                                 if(String(messageArray[h].chatmessage.substr(9 + currentUser.length + 1, 5)) == "_cam_")
  462.                                                 {
  463.                                                     if(camController.videoChatStatus == "starter")
  464.                                                     {
  465.                                                         callPrivateChatBox(messageArray[h].username, "<font color='#000000'>" + "<b>" + messageArray[h].username + " </b>accepted your invitation.<br><b>Hint:</b> In full-screen mode click the <b>Allow</b> button at the top of the screen to be able to type into the private chat box.</font>");
  466.                                                         addInvitedUser(String(messageArray[h].chatmessage.substr(9 + currentUser.length + 6, 300)), messageArray[h].username);
  467.                                                     }
  468.                                                     else
  469.                                                     {
  470.                                                         callPrivateChatBox(messageArray[h].username, "<font color='#000000'>" + "<b>" + messageArray[h].username + " </b>is inviting you to a video call.<br><b>Hint:</b> In full-screen mode click the <b>Allow</b> button at the top of the screen to be able to type into the private chat box.</font>");
  471.                                                         newCamInvitation(String(messageArray[h].chatmessage.substr(9 + currentUser.length + 6, 300)), messageArray[h].username);
  472.                                                     }
  473.                                                 }
  474.                                                 else
  475.                                                 {
  476.                                                     callPrivateChatBox(messageArray[h].username, "<font color='#000000'>" + "<b>" + messageArray[h].username + ": </b>" + String(messageArray[h].chatmessage.substr(9 + currentUser.length + 1,300)) + "</font>");
  477.                                                 }
  478.                                             }
  479.                                         }
  480.                                         else
  481.                                         {                              
  482.                                             soundToPlay = "newPrivateMessage";                                     
  483.                                            
  484.                                             if(String(messageArray[h].chatmessage.substr(9 + currentUser.length + 1, 5)) == "_cam_")
  485.                                             {                                              
  486.                                                 if(camController.videoChatStatus == "starter")
  487.                                                 {
  488.                                                     callPrivateChatBox(messageArray[h].username, "<font color='#000000'>" + "<b>" + messageArray[h].username + " </b>accepted your invitation.<br><b>Hint:</b> In full-screen mode click the <b>Allow</b> button at the top of the screen to be able to type into the private chat box.</font>");
  489.                                                     addInvitedUser(String(messageArray[h].chatmessage.substr(9 + currentUser.length + 6, 300)), messageArray[h].username);
  490.                                                 }
  491.                                                 else
  492.                                                 {
  493.                                                     callPrivateChatBox(messageArray[h].username, "<font color='#000000'>" + "<b>" + messageArray[h].username + " </b>is inviting you to a video call.<br><b>Hint:</b> In full-screen mode click the <b>Allow</b> button at the top of the screen to be able to type into the private chat box.</font>");
  494.                                                     newCamInvitation(String(messageArray[h].chatmessage.substr(9 + currentUser.length + 6, 300)), messageArray[h].username);
  495.                                                 }
  496.                                             }
  497.                                             else
  498.                                             {
  499.                                                 callPrivateChatBox(messageArray[h].username, "<font color='#000000'>" + "<b>" + messageArray[h].username + ": </b>" + String(messageArray[h].chatmessage.substr(9 + currentUser.length + 1,300)) + "</font>");
  500.                                             }
  501.                                         }
  502.                                     }
  503.                                     else if(messageArray[h].chatmessage.substr(0,8) == "/private" &&
  504.                                             messageArray[h].chatmessage.substr(9,currentUser.length) != currentUser)
  505.                                     {
  506.                                         soundToPlay = "none";
  507.                                     }
  508.                                     else
  509.                                     {
  510.                                         soundToPlay = "newMessage";
  511.                                     }
  512.                                 }
  513.                             }
  514.                              
  515.                             if(soundToPlay != "none")
  516.                             {
  517.                                 switch (soundToPlay)
  518.                                 {
  519.                                     case "userEnters" :
  520.                                     trace("-> New user enters the chat");
  521.                                     sound_newUser.play();
  522.                                     break;
  523.                                     case "userLeaves" :
  524.                                     trace("-> User leaves the chat");
  525.                                     sound_exitUser.play();
  526.                                     break;
  527.                                     case "newMessage" :
  528.                                     trace("-> New message incoming");
  529.                                     sound_newMessage.play();
  530.                                     break;
  531.                                     case "newPrivateMessage" :
  532.                                     trace("-> New private message incoming");
  533.                                     sound_newMessage.play();
  534.                                     break;
  535.                                 }
  536.                                 soundToPlay = "none";
  537.                             }
  538.                         }
  539.                     } //Closing tag from if XML > 0
  540.                     else
  541.                     {
  542.                         trace("->SKIPPING MESSAGE UPDATE");
  543.                     }
  544.                 }
  545.                 catch (err:TypeError)
  546.                 {
  547.                     trace("Chat history has become corrupted. Executing auto-reset!");
  548.                    
  549.                     phpRequest = new URLRequest("xml_autoclean.php");
  550.                     phpLoader = new URLLoader();
  551.        
  552.                     vars = new URLVariables();
  553.                     vars.var1 = "resetChatXML";
  554.                        
  555.                     phpRequest.data = vars;
  556.                     phpRequest.method = URLRequestMethod.POST;
  557.                     phpLoader.load(phpRequest);
  558.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  559.                 }
  560.             }
  561.            
  562.  
  563. // FUNCTION processUserXML - Confirm login, check current user status, generate userlist, client overrides for kick and ban, alive ping
  564. // ***************************************************************************************************************************************
  565. // ***************************************************************************************************************************************
  566. // ***************************************************************************************************************************************
  567.  
  568.             /*Updates the userlist window and users online counter*/
  569.             function processUserXML(event:Event):void
  570.             {
  571.                 try
  572.                 {
  573.                 userXML = new XML(event.target.data);
  574.                
  575.                     // If currentUser is not logged in and XML length is greater than 0
  576.                     if(userXML.*.length() > 0 || userEnter != "logged")
  577.                     {
  578.        
  579.                         // reset then populate the userlist array
  580.                         if(userlistArray)
  581.                         {
  582.                             userlistArray = null;
  583.                             userlistArray = new Array();
  584.                             stage.removeChild(userlistContainer);
  585.                             userlistContainer = null;
  586.                         }
  587.            
  588.                         userlistContainer = new userlistContainer_mc();
  589.                         userlistContainer.x = userlistContainerPos_mc.x;
  590.                         userlistContainer.y = userlistContainerPos_mc.y;                   
  591.  
  592.                         stage.addChild(userlistContainer);
  593.                        
  594.                         stage.setChildIndex(userlistContainer, 3);
  595.                        
  596.                         stage.setChildIndex(emoButton, stage.getChildIndex(userlistContainer) + 1);
  597.                         stage.setChildIndex(statusButton, stage.getChildIndex(userlistContainer) + 1);
  598.  
  599.                         userlistContainer.mask = maskingShape; 
  600.                        
  601.                         var yPosition:Number = 0;
  602.                    
  603.                         if(userEnter == "login") // Add new user to Userlist
  604.                         {
  605.                             sa.addText("<font color='" + chatLinkColor + "'><b>Welcome " + currentUser + ", you are now connected to the chat room!</b></font>");
  606.                        
  607.                             if(userXML.*.length() <= 1)
  608.                             {
  609.                                 sa.addText("<font color='" + chatLinkColor + "'>[ 1 User Online ] - You are the only person in the chat room at the moment.</font>");
  610.                             }
  611.                            
  612.                             if(userXML.*.length() > 1)
  613.                             {
  614.                                 sa.addText("<font color='" + chatLinkColor + "'>[ " + String(userXML.*.length()) + " Users Online ] - Enjoy your stay and please use proper chat room etiquette.</font>");
  615.                             }
  616.                        
  617.                         currentDate = new Date();
  618.                        
  619.                         phpRequest = new URLRequest(chatProcessUrl);
  620.                         phpLoader = new URLLoader();
  621.        
  622.                         vars = new URLVariables();
  623.                         vars.var1 = currentUser;
  624.                         vars.var2 = "Enters @";
  625.                        
  626.                         phpRequest.data = vars;
  627.                         phpRequest.method = URLRequestMethod.POST;
  628.                         phpLoader.load(phpRequest);
  629.                         phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  630.                        
  631.                         userEnter = "logged";
  632.                         input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  633.                        
  634.                             if(!camController)
  635.                             {
  636.                                 camController = new CamController(stage, "none", camSessionID, camSessionToken, camSessionAPI);
  637.                                 camController.x = 270;
  638.                                 camController.y = 84;
  639.                                 camController.addEventListener("sendVideoCallInvitation", sendVideoCallInvitation);
  640.                                 camController.addEventListener("placePrivateChatFullScreen", placePrivateChatFullScreen);
  641.                                 camController.addEventListener("closeCamWindow", closeCamWindow);
  642.                                 stage.addChild(camController);
  643.                                 camController.visible = false;
  644.                             }
  645.                         }
  646.                                    
  647.                         for (var i:int = 0; i < userXML.*.length(); i++)
  648.                         {
  649.                             var time:Number;
  650.                             var minutes:Number;
  651.                             var calc:Number;
  652.                             var seconds:Number;
  653.                             var secondsOutput:String;
  654.        
  655.                             time = Number(userXML.entry.online_time[i]) / 60;
  656.                             minutes = Math.floor(time);
  657.                             calc = minutes * 60;
  658.                             seconds = Number(userXML.entry.online_time[i]) - calc;
  659.                            
  660.                             if(seconds < 10)
  661.                             {
  662.                             secondsOutput = "0" + String(seconds);
  663.                             }
  664.                             else
  665.                             {
  666.                             secondsOutput = String(seconds);
  667.                             }
  668.                
  669.                             if(ignoredUsers.length > 0)
  670.                             {
  671.                                 var userIgnored:Boolean = false;
  672.                            
  673.                                 for (var bz:int = 0; bz < ignoredUsers.length; bz++)
  674.                                 {
  675.                                     if(ignoredUsers[bz] == userXML.entry.name[i])
  676.                                     {
  677.                                         userIgnored = true;
  678.                                         break;
  679.                                     }
  680.                                     else
  681.                                     {
  682.                                         userIgnored = false;
  683.                                     }
  684.                                 }
  685.                                
  686.                                 if(userIgnored == false)
  687.                                 {
  688.                                     userlistArray.push({username:userXML.entry.name[i], userstatus:userXML.entry.user_love[i], userphoto:userXML.entry.user_photo[i], minutes:minutes, seconds:secondsOutput, country:userXML.entry.user_country[i], city:userXML.entry.user_city[i]});
  689.                                     userIgnored = false;
  690.                                 }
  691.                             }
  692.                             else
  693.                             {                              
  694.                                 userlistArray.push({username:userXML.entry.name[i], userstatus:userXML.entry.user_love[i], userphoto:userXML.entry.user_photo[i], minutes:minutes, seconds:secondsOutput, country:userXML.entry.user_country[i], city:userXML.entry.user_city[i]});
  695.                             }
  696.                            
  697.                             var chatKilled:Boolean = false;
  698.                            
  699.                             if(userXML.entry.user_love[i] == "kick" && userXML.entry.name[i] == currentUser)
  700.                             {
  701.                             //destroy chat!        
  702.                             sa.addText("<font color='" + chatLinkColor + "'><b>>> You have been kicked from the chat!</b></font>");
  703.                            
  704.                             destroyPrivateChatBoxes();
  705.                             updateTimerChat.stop();
  706.                             updateTimerChat.removeEventListener(TimerEvent.TIMER, updateChatData); // Chat window data refresh Timer
  707.                             updateTimerUserlist.stop();
  708.                             updateTimerUserlist.removeEventListener(TimerEvent.TIMER, updateUserListData); // Chat window data refresh Timer
  709.                             send_btn.removeEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  710.                             input_txt.removeEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  711.                             logout_btn.removeEventListener(MouseEvent.CLICK, onLogout);
  712.                             userlistContainer.visible = false;
  713.                             chatKilled = true;
  714.                             userEnter = "logout";
  715.                             currentUser = "notConnected";
  716.                             }
  717.                            
  718.                             if(userXML.entry.user_love[i] == "ban" && userXML.entry.name[i] == currentUser)
  719.                             {
  720.                             //ban IP and destroy chat!
  721.                             phpRequest = new URLRequest(userProcessUrl);
  722.                             phpLoader = new URLLoader();
  723.                            
  724.                             vars = new URLVariables();
  725.                             vars.var1 = currentUser;
  726.                             vars.var2 = "suicide";
  727.                             vars.var3 = "suicide";
  728.                                            
  729.                             phpRequest.data = vars;
  730.                             phpRequest.method = URLRequestMethod.POST;
  731.                             phpLoader.load(phpRequest);
  732.                             phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  733.                            
  734.                             sa.addText("<font color='" + chatLinkColor + "'><b>>> You have been banned from the chat!</b></font>");
  735.                            
  736.                             destroyPrivateChatBoxes();
  737.                             updateTimerChat.stop();
  738.                             updateTimerChat.removeEventListener(TimerEvent.TIMER, updateChatData); // Chat window data refresh Timer
  739.                             updateTimerUserlist.stop();
  740.                             updateTimerUserlist.removeEventListener(TimerEvent.TIMER, updateUserListData); // Chat window data refresh Timer
  741.                             send_btn.removeEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  742.                             input_txt.removeEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  743.                             logout_btn.removeEventListener(MouseEvent.CLICK, onLogout);
  744.                             userlistContainer.visible = false;
  745.                             chatKilled = true;
  746.                             userEnter = "logout";
  747.                             currentUser = "notConnected";
  748.                            
  749.                             banCookie.data.userlove = "banned";
  750.                             banCookie.flush();
  751.                             }
  752.                         }
  753.                        
  754.                         scrollButton_mc.removeEventListener(MouseEvent.MOUSE_DOWN, initalizeDragObject);
  755.                         yPosition = 0;
  756.                        
  757.                         if(chatKilled == false)
  758.                         {
  759.                             for (var m:int = 0; m < userlistArray.length; m++)
  760.                             {
  761.                                 userlistButton = new userlistButton_mc();
  762.                                 userlistButton.y = yPosition;
  763.                                 userlistButton.x = 0;
  764.                                
  765.                                 if(userlistArray[m].userstatus == "available")
  766.                                 {
  767.                                     userlistButton.username_txt.textColor = 0xFFFFFF;
  768.                                     userlistButton.onlineTime_txt.textColor = 0xFD8300;
  769.                                    
  770.                                     if(userlistArray[m].country == "unknown" || userlistArray[m].country == "null")
  771.                                     {
  772.                                         userlistButton.country = "unknown";
  773.                                         userlistButton.city = "unknown";
  774.                                         userlistButton.onlineTime_txt.text = "Online - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  775.                                     }
  776.                                     else
  777.                                     {
  778.                                         userlistButton.country = userlistArray[m].country;
  779.                                         userlistButton.city = userlistArray[m].city;
  780.                                         userlistButton.onlineTime_txt.text = userlistArray[m].country + " - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  781.                                     }
  782.                                 }
  783.                                 else if(userlistArray[m].userstatus == "away")
  784.                                 {
  785.                                     userlistButton.username_txt.textColor = 0x999999;
  786.                                     userlistButton.onlineTime_txt.textColor = 0x999999;
  787.                                    
  788.                                     if(userlistArray[m].country == "unknown" || userlistArray[m].country == "null")
  789.                                     {
  790.                                         userlistButton.country = "unknown";
  791.                                         userlistButton.city = "unknown";
  792.                                         userlistButton.onlineTime_txt.text = "Busy - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  793.                                     }
  794.                                     else
  795.                                     {
  796.                                         userlistButton.country = userlistArray[m].country;
  797.                                         userlistButton.city = userlistArray[m].city;
  798.                                         userlistButton.onlineTime_txt.text = "Busy - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  799.                                     }
  800.                                 }
  801.                                
  802.                                 userlistButton.username_txt.text = userlistArray[m].username;
  803.                                 userlistButton.username = userlistArray[m].username;
  804.                                 userlistButton.userphoto = userlistArray[m].userphoto;
  805.                                 userlistButton.userstatus = userlistArray[m].userstatus;
  806.                                 userlistButton.currentUser = currentUser;
  807.                                 userlistButton.chatProcessUrl = chatProcessUrl;
  808.            
  809.                                 if(userlistButtonArray.length == 0)
  810.                                 {
  811.                                     userlistButtonArray.push(userlistButton);
  812.                                     userlistContainer.addChild(userlistButton);
  813.                                     userlistButtonFunctionality(userlistButton);
  814.                                     getUserPhoto(userlistArray[m].userphoto, userlistButton);
  815.                                 }
  816.                                 else
  817.                                 {
  818.                                     var userButtonFound:Boolean = true;
  819.                                    
  820.                                     for (var t:int = 0; t < userlistButtonArray.length; t++)
  821.                                     {
  822.                                         if(userlistButtonArray[t].username != userlistButton.username)
  823.                                         {
  824.                                             userButtonFound = false;
  825.                                         }
  826.                                         else
  827.                                         {
  828.                                             // exisiting user button is checked for avatar picture change
  829.                                             if(userlistButtonArray[t].userphoto == userlistButton.userphoto)
  830.                                             {
  831.                                                 userButtonFound = true;
  832.                                                 break;
  833.                                             }
  834.                                         }
  835.                                     }
  836.                                    
  837.                                     if(userButtonFound == false)
  838.                                     {
  839.                                         userlistButtonArray.push(userlistButton);
  840.                                         userlistContainer.addChild(userlistButton);
  841.                                         userlistButtonFunctionality(userlistButton);
  842.                                         getUserPhoto(userlistArray[m].userphoto, userlistButton);
  843.                                         userButtonFound = true;
  844.                                     }
  845.                                     else
  846.                                     {
  847.                                         if(userlistArray[m].userstatus == "available")
  848.                                         {
  849.                                             userlistButtonArray[t].username_txt.textColor = 0xFFFFFF;
  850.                                             userlistButtonArray[t].onlineTime_txt.textColor = 0xFD8300;
  851.                                            
  852.                                             if(userlistArray[m].country == "unknown" || userlistArray[m].country == "null")
  853.                                             {
  854.                                                 userlistButtonArray[t].country = "unknown";
  855.                                                 userlistButtonArray[t].city = "unknown";
  856.                                                 userlistButtonArray[t].onlineTime_txt.text = "Online - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  857.                                             }
  858.                                             else
  859.                                             {
  860.                                                 userlistButtonArray[t].country = userlistArray[m].country;
  861.                                                 userlistButtonArray[t].city = userlistArray[m].city;
  862.                                                 userlistButtonArray[t].onlineTime_txt.text = userlistArray[m].country + " - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  863.                                             }
  864.                                         }
  865.                                         else if(userlistArray[m].userstatus == "away")
  866.                                         {
  867.                                             userlistButtonArray[t].username_txt.textColor = 0x999999;
  868.                                             userlistButtonArray[t].onlineTime_txt.textColor = 0x999999;
  869.                                            
  870.                                             if(userlistArray[m].country == "unknown" || userlistArray[m].country == "null")
  871.                                             {
  872.                                                 userlistButtonArray[t].country = "unknown";
  873.                                                 userlistButtonArray[t].city = "unknown";
  874.                                                 userlistButtonArray[t].onlineTime_txt.text = "Busy - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  875.                                             }
  876.                                             else
  877.                                             {
  878.                                                 userlistButtonArray[t].country = userlistArray[m].country;
  879.                                                 userlistButtonArray[t].city = userlistArray[m].city;
  880.                                                 userlistButtonArray[t].onlineTime_txt.text = "Busy - " + userlistArray[m].minutes + ":" + userlistArray[m].seconds;
  881.                                             }
  882.                                         }
  883.                                        
  884.                                         userlistButtonArray[t].y = yPosition;
  885.                                         userlistButtonArray[t].x = 0;
  886.                                         userlistButtonArray[t].username_txt.text = userlistArray[m].username;
  887.                                         userlistButtonArray[t].username = userlistArray[m].username;
  888.                                         userlistButtonArray[t].userstatus = userlistArray[m].userstatus;
  889.                                         userlistButtonArray[t].currentUser = currentUser;
  890.                                         userlistButtonArray[t].chatProcessUrl = chatProcessUrl;
  891.        
  892.                                         userlistContainer.addChild(userlistButtonArray[t]);
  893.                                         userlistButtonFunctionality(userlistButtonArray[t]);
  894.                                     }
  895.                                 }
  896.                                 yPosition += userlistButton.height + 1;
  897.                             }
  898.                         }
  899.                        
  900.                         // Checking if user has been disconnected accidently
  901.                        
  902.                         if(currentUser != "notConnected")
  903.                         {
  904.                             currentUserListed = true;
  905.                            
  906.                             for (var uf:int = 0; uf < userlistArray.length; uf++)
  907.                             {
  908.                                 if(userlistArray[uf].username == currentUser)
  909.                                 {
  910.                                     currentUserListed = true;
  911.                                     userNotFoundCounter = 0;
  912.                                     break;
  913.                                 }
  914.                                 else
  915.                                 {
  916.                                     currentUserListed = false;
  917.                                 }
  918.                             }
  919.                            
  920.                             if(currentUserListed == false)
  921.                             {
  922.                                 userNotFoundCounter ++;
  923.                                
  924.                                 if(userNotFoundCounter == 3)
  925.                                 {
  926.                                     userNotFoundCounter = 0;
  927.                                     forceReLogin();
  928.                                 }
  929.                             }
  930.                         }
  931.                        
  932.                         scrollButton_mc.addEventListener(MouseEvent.MOUSE_DOWN, initalizeDragObject);              
  933.                         userlistContainer.y = -(userlistY -(userlistInitPos*2));
  934.                        
  935.                         if(userXML.*.length() <= 3)
  936.                         {
  937.                             updateTimerChat.delay = 2000;
  938.                             updateTimerUserlist.delay = 3000;
  939.                         }
  940.                         else if(userXML.*.length() > 3 && userXML.*.length() <= 5)
  941.                         {
  942.                             updateTimerChat.delay = 3000;
  943.                             updateTimerUserlist.delay = 4000;
  944.                         }
  945.                         else if(userXML.*.length() > 5 && userXML.*.length() <= 10)
  946.                         {
  947.                             updateTimerChat.delay = 3000;
  948.                             updateTimerUserlist.delay = 5000;
  949.                         }
  950.                         else if(userXML.*.length() > 10 && userXML.*.length() <= 15)
  951.                         {
  952.                             updateTimerChat.delay = 5000;
  953.                             updateTimerUserlist.delay = 8000;
  954.                         }
  955.                         else if(userXML.*.length() > 15)
  956.                         {
  957.                             updateTimerChat.delay = 7000;
  958.                             updateTimerUserlist.delay = 10000;
  959.                         }
  960.                        
  961.                         status_txt.htmlText = "<b>" + String(userXML.*.length()) + "</b> User(s) Online";
  962.                         userscroll_cmp.scrollPosition = userscroll_cmp.minScrollPosition; // Moves the SCROLL BAR to end of chat message text
  963.                            
  964.                         phpRequest = new URLRequest(userProcessUrl);
  965.                         phpLoader = new URLLoader();
  966.                        
  967.                         vars = new URLVariables();
  968.                         vars.var1 = currentUser;
  969.                         vars.var2 = "null";
  970.                         vars.var3 = "ping";
  971.                                        
  972.                         phpRequest.data = vars;
  973.                         phpRequest.method = URLRequestMethod.POST;
  974.                         phpLoader.load(phpRequest);
  975.                         phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  976.                     } //Closing tag from if XML > 0
  977.                     else
  978.                     {
  979.                         trace("-> SKIPPING USERLIST UPDATE");
  980.                        
  981.                         if(userXML.*.length() <= 0 && userEnter == "logged")
  982.                         {
  983.                             userNotFoundCounter ++;
  984.                            
  985.                             if(userNotFoundCounter == 3)
  986.                             {
  987.                                 userNotFoundCounter = 0;
  988.                                 forceReLogin();
  989.                             }
  990.                         }
  991.                         else
  992.                         {
  993.                             userNotFoundCounter = 0;
  994.                         }
  995.                     }
  996.                 }
  997.                 catch (err:TypeError)
  998.                 {
  999.                     trace("Chat userlist has become corrupted. Executing auto-reset!" + err);
  1000.                    
  1001.                     phpRequest = new URLRequest("xml_autoclean.php");
  1002.                     phpLoader = new URLLoader();
  1003.        
  1004.                     vars = new URLVariables();
  1005.                     vars.var1 = "resetUserXML";
  1006.                        
  1007.                     phpRequest.data = vars;
  1008.                     phpRequest.method = URLRequestMethod.POST;
  1009.                     phpLoader.load(phpRequest);
  1010.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1011.                 }
  1012.             }
  1013.  
  1014.             function getUserPhoto(userPhoto:String, currentButton:MovieClip)
  1015.             {
  1016.                 if(userPhoto != "none" && userPhoto != null && userPhoto.substr(0,4) != "http")
  1017.                 {                          
  1018.                     var imageRequest:URLRequest = new URLRequest("upload/" + userPhoto);
  1019.                     var imageLoader:Loader = new Loader();
  1020.                     imageLoader.load(imageRequest);
  1021.                     imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1022.                     imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadMyAvatarPictureComplete);
  1023.                 }
  1024.                 else if (userPhoto != "none" && userPhoto != null && userPhoto.substr(0,4) == "http")
  1025.                 {
  1026.                     var lc:LoaderContext = new LoaderContext();
  1027.                     lc.checkPolicyFile = false;
  1028.                    
  1029.                     imageLoader = new Loader();
  1030.                     imageRequest = new URLRequest(userPhoto);
  1031.                     imageLoader.load(imageRequest, lc);
  1032.                     imageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onImageLoaded);
  1033.                     imageLoader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1034.                 }
  1035.                 else
  1036.                 {
  1037.                     currentButton.userlistButtonIconContainer_mc.visible = false;
  1038.                 }
  1039.                
  1040.                 function onImageLoaded($e:Event):void
  1041.                 {
  1042.                     var _innerImage:Sprite = currentButton.userlistButtonIconContainer_mc.addChild(new Sprite());
  1043.                     imageLoader.x = - Number(Math.ceil(currentButton.userlistButtonIconContainer_mc.width * 0.5) - 1);
  1044.                     imageLoader.y = - Number(Math.ceil(currentButton.userlistButtonIconContainer_mc.height * 0.5) - 1);
  1045.                    
  1046.                     imageLoader.width = 45;
  1047.                     imageLoader.height = 45;
  1048.                     currentButton.userlistButtonIconContainer_mc.addChild(imageLoader);
  1049.                 }
  1050.                
  1051.                 function loadMyAvatarPictureComplete(event:Event):void
  1052.                 {
  1053.                     _bitmap = new Bitmap();
  1054.                     _bitmap = event.target.content;
  1055.                     resizeIt(_bitmap,45,45);
  1056.                     _bitmap.smoothing = true;
  1057.  
  1058.                     _bitmap.x = 0 - _bitmap.width/2;
  1059.                     _bitmap.y = 0 - _bitmap.height/2;
  1060.  
  1061.                     currentButton.userlistButtonIconContainer_mc.addChild(_bitmap);
  1062.                     currentButton.userlistButtonIconContainer_mc.visible = true;
  1063.                 }
  1064.                
  1065.                 function resizeIt(b:Bitmap,maxH:Number,maxW:Number)
  1066.                 {
  1067.                     var r:Number;//ratio
  1068.                     r = b.height/b.width;//calculation ratio to which resize takes place
  1069.                
  1070.                     if (b.width>maxW) {
  1071.                     b.width = maxW;
  1072.                     b.height = Math.round(b.width*r);
  1073.                
  1074.                     }
  1075.                     if (b.height>maxH)
  1076.                     {
  1077.                         b.height = maxH;
  1078.                         b.width = Math.round(b.height/r);
  1079.                     }
  1080.                 }
  1081.             }
  1082.            
  1083.             function forceReLogin():void
  1084.             {
  1085.                 trace("-> TRYING AUTO-RECONNECT");
  1086.                    
  1087.                 phpRequest = new URLRequest(userProcessUrl);
  1088.                 phpLoader = new URLLoader();
  1089.                        
  1090.                 vars = new URLVariables();
  1091.                 vars.var1 = currentUser;
  1092.                 vars.var2 = "available";
  1093.                 vars.var3 = "online";
  1094.                 vars.var4 = pictureFilename;
  1095.                 vars.var5 = country;
  1096.                 vars.var6 = city;
  1097.                                        
  1098.                 phpRequest.data = vars;
  1099.                 phpRequest.method = URLRequestMethod.POST;
  1100.                 phpLoader.load(phpRequest);
  1101.                 phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1102.             }
  1103.            
  1104.  
  1105. // FUNCTION onMessageSend - Processing typed message
  1106. // ***************************************************************************************************************************************
  1107. // ***************************************************************************************************************************************
  1108. // ***************************************************************************************************************************************
  1109.            
  1110.             /*Send message via keypress*/
  1111.             function onMessageSendKeyPress(event:KeyboardEvent):void
  1112.             {
  1113.                 if(event.keyCode == 13 && floodingCounter < 3 && currentUser != "notConnected")
  1114.                 {
  1115.                     chatMessage = String(input_txt.text);
  1116.                     input_txt.text = "";
  1117.                     onMessageSend();
  1118.                 }
  1119.             }  
  1120.        
  1121.             /*Send message via send button click*/
  1122.             function onMessageSendMouseClick(event:MouseEvent):void
  1123.             {
  1124.                 if(floodingCounter < 3 && floodingCounter < 3 && currentUser != "notConnected")
  1125.                 {
  1126.                     chatMessage = String(input_txt.text);
  1127.                     input_txt.text = "";
  1128.                     onMessageSend();
  1129.                 }
  1130.             }
  1131.            
  1132.             /*Sends user message to PHP to save the new data into the chathistory XML*/
  1133.             function onMessageSend():void
  1134.             {
  1135.                 floodingCounter++;
  1136.                
  1137.                 if(firstServerTime != "expired")
  1138.                 {
  1139.                     previousTimeStamp = firstServerTime;
  1140.                     firstServerTime = "expired";
  1141.                 }
  1142.                
  1143.                 var messageTest:String = chatMessage;
  1144.                 messageTest = messageTest.split(" ").join("");
  1145.                
  1146.                 if(messageTest == "")
  1147.                 {
  1148.                     chatMessage = "";
  1149.                 }
  1150.                
  1151.                 var messageForceDisplay:Boolean = true;
  1152.                 var messageBefore:String = String(chatMessage);
  1153.                
  1154.                 function trim(str:String):String
  1155.                 {
  1156.                     return str.replace(/^\s*(.*?)\s*$/g, "$1");
  1157.                 }
  1158.  
  1159.                 chatMessage = trim(chatMessage).replace(/\s{1,}(.*?)/g, "$1 ");
  1160.                 message_str = String(chatMessage);
  1161.                 message_str = message_str.replace(/((https?|ftp|telnet|file):((\/\/)|(\\\\))+[\w\d:#@%\/;$()~_?\+-=\\\.&]*)/g, "<u><a href='$1' target='_blank'><font color='" + chatLinkColor + "'>$1</font></a></u>");
  1162.                
  1163.                 var messageAfter:String = message_str;
  1164.                
  1165.                 if(messageBefore != messageAfter)
  1166.                 {
  1167.                     messageForceDisplay = false;
  1168.                 }
  1169.                
  1170.                 if(String(chatMessage).substr(0,8) == "/private")
  1171.                 {
  1172.                     //sa.addText("<font color='" + chatTextColor + "'>[ " + previousTimeStamp + " ]<b> " + currentUser + ": <font color='" + chatLinkColor + "'>[Private Sent]</font></b> " + message_str + "</font>");
  1173.                    
  1174.                     trace("-> New private message outgoing");
  1175.                    
  1176.                     phpRequest = new URLRequest(chatProcessUrl);
  1177.                     phpLoader = new URLLoader();
  1178.    
  1179.                     vars = new URLVariables();
  1180.                     vars.var1 = currentUser;
  1181.                     vars.var2 = chatMessage;
  1182.                    
  1183.                     phpRequest.data = vars;
  1184.                     phpRequest.method = URLRequestMethod.POST;
  1185.  
  1186.                     phpLoader.load(phpRequest);
  1187.                     phpLoader.addEventListener(Event.COMPLETE, onMessageComplete);
  1188.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1189.                 }
  1190.                
  1191.                 if(String(chatMessage).substr(0,5) == "/help")
  1192.                 {
  1193.                     sa.addText("<font color='" + chatTextColor + "'><b><font color='" + chatLinkColor + "'>[ Chat User Guide ] -----------------------------------------------------------------------------------------</b></font></font>");
  1194.                     sa.addText("<font color='" + chatTextColor + "'><font color='" + chatLinkColor + "'>Start private 1 on 1 chat</font> - Click on a user in the right userlist</font>");
  1195.                     sa.addText("<font color='" + chatTextColor + "'><font color='" + chatLinkColor + "'>Video & voice call</font> - Click on a user and then on the video call button</font>");
  1196.                     sa.addText("<font color='" + chatTextColor + "'><font color='" + chatLinkColor + "'>View rooms list</font> - Type <font color='" + chatLinkColor + "'>/rooms</font> into the chat</font>");
  1197.                     chatMessage = "";
  1198.                 }
  1199.                    
  1200.                 if(String(chatMessage).substr(0,6) == "/rooms")
  1201.                 {
  1202.                    
  1203.                 }
  1204.                        
  1205.                 if(String(chatMessage).substr(0,7) == "/sounds")
  1206.                 {
  1207.                         if(sounds == true)
  1208.                         {
  1209.                         chatMessage = ""
  1210.                         trace ("[Sounds OFF]");
  1211.                         sounds = false;
  1212.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Sounds OFF]</font>");
  1213.                         }
  1214.                         else if(sounds == false)
  1215.                         {
  1216.                         chatMessage = ""
  1217.                         trace ("[Sounds ON]");
  1218.                         sounds = true;
  1219.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Sounds ON]</font>");
  1220.                         }
  1221.                 }
  1222.                        
  1223.                 if(String(chatMessage).substr(0,8) == "/history")
  1224.                 {
  1225.                         chatMessage = "";
  1226.                         trace("[Loading History]");
  1227.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Loading History...]</font>");
  1228.                            
  1229.                         archiveXmlLoader.load(new URLRequest("chatarchive.xml" + "?nocache=" + new Date().getTime()));
  1230.                         archiveXmlLoader.addEventListener(ProgressEvent.PROGRESS, loadArchiveXML);
  1231.                         archiveXmlLoader.addEventListener(Event.COMPLETE, processChatXML);
  1232.                         archiveXmlLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1233.                 }
  1234.                    
  1235.                 if(String(chatMessage).substr(0,6) == "/clear")
  1236.                 {
  1237.                         adminCodeBox.x = 20;
  1238.                         adminCodeBox.y = 20;
  1239.                         addChild(adminCodeBox);
  1240.                        
  1241.                         adminCodeBox.close_btn.addEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1242.                         adminCodeBox.kick_btn.addEventListener(MouseEvent.CLICK, onCodeClear);
  1243.                 }
  1244.                    
  1245.                 if(String(chatMessage).substr(0,5) == "/kick")
  1246.                 {
  1247.                         adminCodeBox.x = 20;
  1248.                         adminCodeBox.y = 20;
  1249.                         addChild(adminCodeBox);
  1250.                        
  1251.                         adminCodeBox.close_btn.addEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1252.                         adminCodeBox.kick_btn.addEventListener(MouseEvent.CLICK, onCodeKick);
  1253.                 }
  1254.                        
  1255.                 if(String(chatMessage).substr(0,4) == "/ban")
  1256.                 {
  1257.                         adminCodeBox.x = 20;
  1258.                         adminCodeBox.y = 20;
  1259.                         addChild(adminCodeBox);
  1260.                            
  1261.                         adminCodeBox.close_btn.addEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1262.                         adminCodeBox.kick_btn.addEventListener(MouseEvent.CLICK, onCodeBan);
  1263.                 }
  1264.                        
  1265.                 if(String(chatMessage).substr(0,1) == "/" &&
  1266.                 String(chatMessage).substr(0,5) != "/help" &&
  1267.                 String(chatMessage).substr(0,7) != "/sounds" &&
  1268.                 String(chatMessage).substr(0,8) != "/private" &&
  1269.                 String(chatMessage).substr(0,5) != "/kick" &&
  1270.                 String(chatMessage).substr(0,8) != "/history" &&
  1271.                 String(chatMessage).substr(0,4) != "/ban" &&
  1272.                 String(chatMessage).substr(0,6) != "/clear" &&
  1273.                 String(chatMessage).substr(0,4) != "/rooms")
  1274.                 {
  1275.                         trace("[Invalid Command]");
  1276.                         sa.addText("<font color='" + chatLinkColor + "'>>> <b>[Invalid Command!]</b> Please type /help to see a list of commands.</font>");
  1277.                         chatMessage = "";
  1278.                 }
  1279.                    
  1280.                 if(String(chatMessage) != "" &&
  1281.                 messageArray.length > 0 &&
  1282.                 String(chatMessage) == String(messageArray[messageArray.length - 1].chatmessage) &&
  1283.                 currentUser == String(messageArray[messageArray.length - 1].username))
  1284.                 {
  1285.                         sa.addText("<font color='" + chatLinkColor + "'>>> <b>[Flood Control]</b> Duplicate messages are not allowed!</font>");
  1286.                         chatMessage = "";
  1287.                 }
  1288.                    
  1289.                 if(String(chatMessage) != "" &&
  1290.                 String(chatMessage).substr(0,6) != "/clear" &&
  1291.                 String(chatMessage).substr(0,5) != "/kick" &&
  1292.                 String(chatMessage).substr(0,8) != "/history" &&
  1293.                 String(chatMessage).substr(0,4) != "/ban")
  1294.                 {                  
  1295.                         phpRequest = new URLRequest(chatProcessUrl);
  1296.                         phpLoader = new URLLoader();
  1297.            
  1298.                         vars = new URLVariables();
  1299.                         vars.var1 = currentUser;
  1300.                         vars.var2 = chatMessage;
  1301.                            
  1302.                         phpRequest.data = vars;
  1303.                         phpRequest.method = URLRequestMethod.POST;
  1304.            
  1305.                         phpLoader.load(phpRequest);
  1306.                         phpLoader.addEventListener(ProgressEvent.PROGRESS, onMessageStart);
  1307.                         phpLoader.addEventListener(Event.COMPLETE, onMessageComplete);
  1308.                         phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1309.                    
  1310.                         if(messageForceDisplay == true)
  1311.                         {
  1312.                             sound_newMessage.play();
  1313.                             chatBoxMessageArray.push({timestamp:previousTimeStamp, username:currentUser, chatmessage:message_str, messagetime:"1"});
  1314.                        
  1315.                             if(chatBoxMessageArray.length >= messageArray.length * 2)
  1316.                             {
  1317.                                 chatBoxMessageArray.splice(0,1);
  1318.                             }
  1319.                            
  1320.                             var pattern:RegExp = /@/i;
  1321.                             if(currentUser.search(pattern) != -1)
  1322.                             {
  1323.                                 sa.addText("<font color='" + adminTextColor + "'><b>" + currentUser + ":</b> " + message_str + "</font>");
  1324.                             }
  1325.                             else
  1326.                             {
  1327.                                 sa.addText("<font color='" + chatTextColor + "'><b>" + currentUser + ":</b> " + message_str + "</font>");
  1328.                             }
  1329.                         }
  1330.                 }
  1331.                
  1332.                 if(String(chatMessage) == "")
  1333.                 {
  1334.  
  1335.                 }
  1336.             }
  1337.  
  1338.             function onMessageStart(event:ProgressEvent):void
  1339.             {
  1340.                 trace("-> Message Sending");
  1341.                 chatMessage = "";
  1342.             }
  1343.  
  1344.             function onMessageComplete(e:Event):void
  1345.             {
  1346.  
  1347.             }
  1348.        
  1349.        
  1350. // Private 1 on 1 Chat
  1351. // ***************************************************************************************************************************************
  1352. // ***************************************************************************************************************************************
  1353. // ***************************************************************************************************************************************         
  1354.            
  1355.             function createNewChatBox(_username:String, _message:String)
  1356.             {
  1357.                 privateChatBox = new privateMessage_mc();
  1358.                 privateChatBox.username = _username;
  1359.  
  1360.                 privateChatBox.x = 20 + Math.round(Math.random()*40);;
  1361.                 privateChatBox.y = 20 + Math.round(Math.random()*40);
  1362.    
  1363.                 privateChatBox.privateMessageDragBox_mc.buttonMode = true;
  1364.                 privateChatBox.privateMessageDragBox_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragPrivateChatBox);
  1365.                 privateChatBox.privateMessageDragBox_mc.addEventListener(MouseEvent.MOUSE_UP, dropPrivateChatBox);
  1366.                                        
  1367.                 privateChatBox.privateMessageTitle_txt.htmlText = "<b>Private chat with " + _username + "</b>";
  1368.                
  1369.                 if(_message != "none")
  1370.                 {
  1371.                     privateChatBox.privateMessage_txt.appendText("\n\n\n\n\n\n\n\n\n\n\n\n\n");
  1372.                     privateChatBox.privateMessage_txt.htmlText = privateChatBox.privateMessage_txt.htmlText + "<font color='#000000'><b>New private chat invitation...</b>\nUser " + privateChatBox.username + " would like to start a private chat with you in this window.\n" + _message + "</font>";
  1373.                 }
  1374.                 else
  1375.                 {
  1376.                     privateChatBox.privateMessage_txt.appendText("\n\n\n\n\n\n\n\n\n\n\n\n\n");
  1377.                     privateChatBox.privateMessage_txt.htmlText = privateChatBox.privateMessage_txt.htmlText + "<font color='#000000'><b>Creating private chat room...</b>\nSend a message in this window to invite user " + privateChatBox.username + " into your private chat room.</font>";
  1378.                 }
  1379.  
  1380.                 privateChatBox.close_btn.addEventListener(MouseEvent.CLICK, onClosePrivateChatBox);
  1381.                 privateChatBox.privateSend_btn.addEventListener(MouseEvent.CLICK, onChatBoxSendMouseClick);
  1382.                 privateChatBox.privateInput_txt.addEventListener(KeyboardEvent.KEY_DOWN, onChatBoxSendKeyPress);
  1383.                
  1384.                 privateChatBox.ignore_btn.addEventListener(MouseEvent.CLICK, onIgnorePrivateChatBox);
  1385.                 privateChatBox.kick_btn.addEventListener(MouseEvent.CLICK, onKickPrivateChatBox);
  1386.                 privateChatBox.ban_btn.addEventListener(MouseEvent.CLICK, onBanPrivateChatBox);
  1387.                
  1388.                 privateChatBox.cam_btn.addEventListener(MouseEvent.CLICK, webCamButtonClick);
  1389.                
  1390.                 chatBoxesArray.push(privateChatBox);
  1391.                 stage.addChild(privateChatBox);
  1392.                
  1393.                 privateBoxesScrollTimer.addEventListener(TimerEvent.TIMER, privateBoxesScrollMax);
  1394.                 privateBoxesScrollTimer.start();
  1395.             }
  1396.            
  1397.             function privateBoxesScrollMax(event:TimerEvent):void
  1398.             {
  1399.                 for (var ih:int = 0; ih < chatBoxesArray.length; ih++)
  1400.                 {
  1401.                     chatBoxesArray[ih].textScroller.scrollPosition = chatBoxesArray[ih].textScroller.maxScrollPosition;
  1402.                 }
  1403.                
  1404.                 privateBoxesScrollTimer.removeEventListener(TimerEvent.TIMER, privateBoxesScrollMax);
  1405.                 privateBoxesScrollTimer.stop();
  1406.             }
  1407.  
  1408.             function onIgnorePrivateChatBox(event:MouseEvent):void
  1409.             {
  1410.                 if(event.target.parent.username != currentUser)
  1411.                 {
  1412.                     privateChatBox.ignore_btn.removeEventListener(MouseEvent.CLICK, onIgnorePrivateChatBox);
  1413.                     event.target.parent.visible = false;
  1414.                     ignoredUsers.push(event.target.parent.username);
  1415.                 }
  1416.                 else
  1417.                 {
  1418.                     event.target.parent.privateMessage_txt.htmlText = event.target.parent.privateMessage_txt.htmlText + "<b>System Message: </b>You cannot ignore yourself.";
  1419.                     event.target.parent.textScroller.scrollPosition = event.target.parent.textScroller.maxScrollPosition;
  1420.                     stage.setChildIndex(event.target.parent, stage.numChildren - 1);
  1421.                 }
  1422.             }
  1423.            
  1424.             function onKickPrivateChatBox(event:MouseEvent):void
  1425.             {
  1426.                 privateChatBox.kick_btn.removeEventListener(MouseEvent.CLICK, onKickPrivateChatBox);
  1427.                 event.target.parent.visible = false;
  1428.                 adminActionOnUser = event.target.parent.username;
  1429.                
  1430.                 adminCodeBox.x = 20;
  1431.                 adminCodeBox.y = 20;
  1432.                 addChild(adminCodeBox);
  1433.                        
  1434.                 adminCodeBox.close_btn.addEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1435.                 adminCodeBox.kick_btn.addEventListener(MouseEvent.CLICK, onCodeKick);
  1436.             }
  1437.            
  1438.             function onBanPrivateChatBox(event:MouseEvent):void
  1439.             {
  1440.                 privateChatBox.ban_btn.removeEventListener(MouseEvent.CLICK, onBanPrivateChatBox);
  1441.                 event.target.parent.visible = false;
  1442.                 adminActionOnUser = event.target.parent.username;
  1443.                
  1444.                 adminCodeBox.x = 20;
  1445.                 adminCodeBox.y = 20;
  1446.                 addChild(adminCodeBox);
  1447.                        
  1448.                 adminCodeBox.close_btn.addEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1449.                 adminCodeBox.kick_btn.addEventListener(MouseEvent.CLICK, onCodeBan);
  1450.             }
  1451.            
  1452.             function callPrivateChatBox(_username:String, _message:String)
  1453.             {
  1454.                 var chatBoxFound:Boolean = false;
  1455.            
  1456.                 for (var ih:int = 0; ih < chatBoxesArray.length; ih++)
  1457.                 {
  1458.                     if(chatBoxesArray[ih].username != _username)
  1459.                     {
  1460.                         chatBoxFound = false;
  1461.                     }
  1462.                     else
  1463.                     {
  1464.                         chatBoxFound = true;
  1465.                         break;
  1466.                     }
  1467.                 }
  1468.                
  1469.                 if(chatBoxFound == false)
  1470.                 {
  1471.                     createNewChatBox(_username, _message);
  1472.                 }
  1473.                 else
  1474.                 {
  1475.                     chatBoxesArray[ih].visible = true;
  1476.                    
  1477.                     if(_message != "none")
  1478.                     {
  1479.                         chatBoxesArray[ih].privateMessage_txt.htmlText = chatBoxesArray[ih].privateMessage_txt.htmlText + _message;
  1480.                         chatBoxesArray[ih].textScroller.scrollPosition = chatBoxesArray[ih].textScroller.maxScrollPosition;
  1481.                         stage.setChildIndex(chatBoxesArray[ih], stage.numChildren - 1);
  1482.                     }
  1483.                 }
  1484.             }
  1485.            
  1486.             function placePrivateChatFullScreen(event:Event):void
  1487.             {              
  1488.                 var chatBoxFound:Boolean = false;
  1489.            
  1490.                 for (var ih:int = 0; ih < chatBoxesArray.length; ih++)
  1491.                 {
  1492.                     if(chatBoxesArray[ih].username != camController.userToInvite)
  1493.                     {
  1494.                         chatBoxFound = false;
  1495.                     }
  1496.                     else
  1497.                     {
  1498.                         chatBoxFound = true;
  1499.                         break;
  1500.                     }
  1501.                 }
  1502.                
  1503.                 if(chatBoxFound == true)
  1504.                 {
  1505.                     stage.setChildIndex(chatBoxesArray[ih], stage.numChildren - 1);
  1506.                 }
  1507.             }
  1508.            
  1509.             function onChatBoxSendMouseClick(event:MouseEvent):void
  1510.             {
  1511.                 if(event.target.parent.privateInput_txt.text != "" && floodingCounter < 3 && currentUser != "notConnected")
  1512.                 {
  1513.                     sendPrivateMessage(event.target.parent, event.target.parent.username, event.target.parent.privateInput_txt.text);
  1514.                     event.target.parent.privateInput_txt.text = "";
  1515.                 }
  1516.             }
  1517.            
  1518.             function onChatBoxSendKeyPress(event:KeyboardEvent):void
  1519.             {
  1520.                 if(event.keyCode == 13 && event.target.parent.privateInput_txt.text != "" && floodingCounter < 3 && currentUser != "notConnected")
  1521.                 {
  1522.                     sendPrivateMessage(event.target.parent, event.target.parent.username, event.target.parent.privateInput_txt.text);
  1523.                     event.target.parent.privateInput_txt.text = "";
  1524.                 }
  1525.             }  
  1526.            
  1527.             function sendPrivateMessage(_chatbox:MovieClip, _username:String, _message:String):void
  1528.             {
  1529.                 selectedChatBox = _chatbox;
  1530.                
  1531.                 floodingCounter++;
  1532.                
  1533.                 if(firstServerTime != "expired")
  1534.                 {
  1535.                     previousTimeStamp = firstServerTime;
  1536.                     firstServerTime = "expired";
  1537.                 }
  1538.                
  1539.                 var messageTest:String = _message;
  1540.                 messageTest = messageTest.split(" ").join("");
  1541.                
  1542.                 if(messageTest == "")
  1543.                 {
  1544.                     _message = "";
  1545.                 }
  1546.  
  1547.                 if(_message != "")
  1548.                 {
  1549.                     _message = trim(_message).replace(/\s{1,}(.*?)/g, "$1 ");
  1550.                     var messageCleaned:String = String(_message);
  1551.                     message_str = String(_message);
  1552.                     message_str = message_str.replace(/((https?|ftp|telnet|file):((\/\/)|(\\\\))+[\w\d:#@%\/;$()~_?\+-=\\\.&]*)/g, "<u><a href='$1' target='_blank'><font color='" + chatLinkColor + "'>$1</font></a></u>");
  1553.                     _message = message_str;
  1554.    
  1555.                     selectedChatBox.privateMessage_txt.htmlText = selectedChatBox.privateMessage_txt.htmlText + "<font color='#000000'><b>" + currentUser + ":</b> " + _message + "</font>";
  1556.                     selectedChatBox.textScroller.scrollPosition = selectedChatBox.textScroller.maxScrollPosition;
  1557.    
  1558.                     //sa.addText("<font color='" + chatTextColor + "'>[ " + previousTimeStamp + " ]<b> " + currentUser + ": <font color='" + chatLinkColor + "'>[to " + _username + "]</font></b> " + _message + "</font>");
  1559.                     sound_newMessage.play();
  1560.                     trace("-> New private message outgoing");
  1561.                        
  1562.                     phpRequest = new URLRequest(chatProcessUrl);
  1563.                     phpLoader = new URLLoader();
  1564.        
  1565.                     vars = new URLVariables();
  1566.                     vars.var1 = currentUser;
  1567.                     vars.var2 = "/private " + _username + " " + messageCleaned;
  1568.  
  1569.                     phpRequest.data = vars;
  1570.                     phpRequest.method = URLRequestMethod.POST;
  1571.  
  1572.                     phpLoader.load(phpRequest);
  1573.                     phpLoader.addEventListener(Event.COMPLETE, onSendPrivateMessageComplete);
  1574.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1575.                 }
  1576.                 else
  1577.                 {
  1578.  
  1579.                 }
  1580.                
  1581.                 function trim(str:String):String
  1582.                 {
  1583.                     return str.replace(/^\s*(.*?)\s*$/g, "$1");
  1584.                 }
  1585.             }
  1586.            
  1587.             function onSendPrivateMessageComplete(e:Event):void
  1588.             {
  1589.  
  1590.             }
  1591.            
  1592.             function dragPrivateChatBox(event:MouseEvent):void
  1593.             {
  1594.                 stage.setChildIndex(event.target.parent, stage.numChildren - 1);
  1595.                 event.target.parent.startDrag();
  1596.             }
  1597.                    
  1598.             function dropPrivateChatBox(event:MouseEvent):void
  1599.             {
  1600.                 event.target.parent.stopDrag();
  1601.             }
  1602.            
  1603.             function onClosePrivateChatBox(event:MouseEvent):void
  1604.             {
  1605.                 event.target.parent.visible = false;
  1606.             }
  1607.            
  1608.             function destroyPrivateChatBoxes():void
  1609.             {
  1610.                 if(chatBoxesArray)
  1611.                 {  
  1612.                     for (var xd:int = 0; xd < chatBoxesArray.length; xd++)
  1613.                     {
  1614.                         stage.removeChild(chatBoxesArray[xd]);
  1615.                     }
  1616.                    
  1617.                     chatBoxesArray = null;
  1618.                     chatBoxesArray = new Array();
  1619.                 }
  1620.             }
  1621.            
  1622.        
  1623. // CHAT COMMAND FUNCTIONS - Process called chat commands
  1624. // ***************************************************************************************************************************************
  1625. // ***************************************************************************************************************************************
  1626. // ***************************************************************************************************************************************
  1627.  
  1628.  
  1629.             // Loading Chat History Function
  1630.             function loadArchiveXML(event:ProgressEvent):void
  1631.             {
  1632.                 var per = event.bytesLoaded/event.bytesTotal;
  1633.                
  1634.                 input_txt.text = "Loading Chat History. Please wait... " + "Total: " + String(event.bytesTotal) + " Bytes - Loaded: " + String(event.bytesLoaded) + " Bytes";
  1635.            
  1636.                 if(Number(event.bytesTotal) >= 50000)
  1637.                 {
  1638.                     input_txt.text = "";
  1639.                     sa.addText("<font color='" + chatLinkColor + "'>>> History XML file has become too large to load. Please reset.</font>");
  1640.                     injectingHistory = false;
  1641.                     archiveXmlLoader.removeEventListener(Event.COMPLETE, processChatXML);
  1642.                     archiveXmlLoader.removeEventListener(ProgressEvent.PROGRESS, loadArchiveXML);
  1643.                 }
  1644.                
  1645.                 if(Number(event.bytesTotal) <= 50000)
  1646.                 {
  1647.                     if(Math.round(per*10*10) == 100)
  1648.                     {
  1649.                         input_txt.text = "";
  1650.                         trace("[Injecting History]");
  1651.                         injectingHistory = true;
  1652.                     }
  1653.                 }
  1654.             }
  1655.            
  1656.             // Administrator Password Box Functions
  1657.             function onClosePasswordBox(event:MouseEvent):void
  1658.             {
  1659.                 input_txt.text = "";
  1660.                 input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  1661.                 send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  1662.                
  1663.                 adminCodeBox.adminCodeError_txt.text = "";
  1664.                 adminCodeBox.adminCode_txt.text = "";
  1665.                 adminCodeBox.close_btn.removeEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1666.                 adminCodeBox.kick_btn.removeEventListener(MouseEvent.CLICK, onCodeBan);
  1667.                 adminCodeBox.kick_btn.removeEventListener(MouseEvent.CLICK, onCodeKick);
  1668.                 adminCodeBox.kick_btn.removeEventListener(MouseEvent.CLICK, onCodeClear);
  1669.                 removeChild(adminCodeBox);
  1670.                 input_txt.text = "";
  1671.             }  
  1672.            
  1673.            
  1674.             function onCodeKick(event:MouseEvent):void
  1675.             {
  1676.                 if(String(adminCodeBox.adminCode_txt.text) == adminCode)
  1677.                 {
  1678.                     phpRequest = new URLRequest(userProcessUrl);
  1679.                     phpLoader = new URLLoader();
  1680.                    
  1681.                     vars = new URLVariables();
  1682.                    
  1683.                     if(adminActionOnUser != "")
  1684.                     {
  1685.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Kicking User] " + String(adminActionOnUser) + "</font>");
  1686.                         vars.var1 = String(adminActionOnUser);
  1687.                     }
  1688.                     else if(chatMessage != "")
  1689.                     {
  1690.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Kicking User] " + String(chatMessage).substr(6,20) + "</font>");
  1691.                         vars.var1 = String(chatMessage).substr(6,20);
  1692.                     }
  1693.                    
  1694.                     adminActionOnUser = "";
  1695.                    
  1696.                     vars.var2 = "kick";
  1697.                     vars.var3 = "kick";
  1698.                                        
  1699.                     phpRequest.data = vars;
  1700.                     phpRequest.method = URLRequestMethod.POST;
  1701.                     phpLoader.load(phpRequest);
  1702.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1703.                    
  1704.                     input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  1705.                     send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  1706.                    
  1707.                     adminCodeBox.adminCodeError_txt.text = "";
  1708.                     adminCodeBox.adminCode_txt.text = "";
  1709.                     adminCodeBox.close_btn.removeEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1710.                     adminCodeBox.kick_btn.removeEventListener(MouseEvent.CLICK, onCodeKick);
  1711.                     removeChild(adminCodeBox);
  1712.                     input_txt.text = "";
  1713.                 }
  1714.                
  1715.                 if(String(adminCodeBox.adminCode_txt.text) != adminCode && String(adminCodeBox.adminCode_txt.text) != "")
  1716.                 {
  1717.                     adminCodeBox.adminCodeError_txt.text = "Wrong Password!";
  1718.                     adminCodeBox.adminCode_txt.text = "";
  1719.                 }
  1720.             }
  1721.            
  1722.            
  1723.             function onCodeBan(event:MouseEvent):void
  1724.             {
  1725.                 if(String(adminCodeBox.adminCode_txt.text) == adminCode)
  1726.                 {
  1727.                     phpRequest = new URLRequest(userProcessUrl);
  1728.                     phpLoader = new URLLoader();
  1729.                        
  1730.                     vars = new URLVariables();
  1731.                    
  1732.                     if(adminActionOnUser != "")
  1733.                     {
  1734.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Banning User] " + String(adminActionOnUser) + "</font>");
  1735.                         vars.var1 = String(adminActionOnUser);
  1736.                     }
  1737.                     else if(chatMessage != "")
  1738.                     {
  1739.                         sa.addText("<font color='" + chatLinkColor + "'>>> [Banning User] " + String(chatMessage).substr(5,20) + "</font>");
  1740.                         vars.var1 = String(chatMessage).substr(5,20);
  1741.                     }
  1742.                    
  1743.                     adminActionOnUser = "";
  1744.                    
  1745.                     vars.var2 = "ban";
  1746.                     vars.var3 = "ban";
  1747.                                        
  1748.                     phpRequest.data = vars;
  1749.                     phpRequest.method = URLRequestMethod.POST;
  1750.                     phpLoader.load(phpRequest);
  1751.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1752.                    
  1753.                     input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  1754.                     send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  1755.                    
  1756.                     adminCodeBox.adminCodeError_txt.text = "";
  1757.                     adminCodeBox.adminCode_txt.text = "";
  1758.                     adminCodeBox.close_btn.removeEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1759.                     adminCodeBox.kick_btn.removeEventListener(MouseEvent.CLICK, onCodeBan);
  1760.                     removeChild(adminCodeBox);
  1761.                     input_txt.text = "";
  1762.                 }
  1763.                
  1764.                 if(String(adminCodeBox.adminCode_txt.text) != adminCode && String(adminCodeBox.adminCode_txt.text) != "")
  1765.                 {
  1766.                     adminCodeBox.adminCodeError_txt.text = "Wrong Password!";
  1767.                     adminCodeBox.adminCode_txt.text = "";
  1768.                 }
  1769.             }  
  1770.  
  1771.             // Clearing Chat History XML Files Function
  1772.             function onCodeClear(event:MouseEvent):void
  1773.             {
  1774.                 if(String(adminCodeBox.adminCode_txt.text) == adminCode)
  1775.                 {
  1776.                     phpRequest = new URLRequest(chatFunctionsUrl);
  1777.                     phpLoader = new URLLoader();
  1778.    
  1779.                     vars = new URLVariables();
  1780.                     vars.var2 = "clear";
  1781.                     vars.var3 = "clear";
  1782.                                        
  1783.                     phpRequest.data = vars;
  1784.                     phpRequest.method = URLRequestMethod.POST;
  1785.                     phpLoader.load(phpRequest);
  1786.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1787.                    
  1788.                     sa.addText("<font color='" + chatLinkColor + "'>>> [History Cleared]</font>");
  1789.    
  1790.                     input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  1791.                     send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  1792.                    
  1793.                     adminCodeBox.adminCodeError_txt.text = "";
  1794.                     adminCodeBox.adminCode_txt.text = "";
  1795.                     adminCodeBox.close_btn.removeEventListener(MouseEvent.CLICK, onClosePasswordBox);
  1796.                     adminCodeBox.kick_btn.removeEventListener(MouseEvent.CLICK, onCodeClear);
  1797.                     removeChild(adminCodeBox);
  1798.                     input_txt.text = "";
  1799.                 }
  1800.                
  1801.                 if(String(adminCodeBox.adminCode_txt.text) != adminCode && String(adminCodeBox.adminCode_txt.text) != "")
  1802.                 {
  1803.                     adminCodeBox.adminCodeError_txt.text = "Wrong Password!";
  1804.                     adminCodeBox.adminCode_txt.text = "";
  1805.                 }
  1806.             }
  1807.  
  1808.  
  1809. // FUNCTION onLogout - Logout the user and send the logout command to PHP to remove the user name from the userlist
  1810. // ***************************************************************************************************************************************
  1811. // ***************************************************************************************************************************************
  1812. // ***************************************************************************************************************************************
  1813.  
  1814.             function onLogout(event:MouseEvent):void
  1815.             {
  1816.                 if(currentUser != "notConnected")
  1817.                 {
  1818.                     logout_btn.removeEventListener(MouseEvent.CLICK, onLogout);
  1819.                     send_btn.removeEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  1820.                     input_txt.removeEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  1821.                    
  1822.                     updateTimerChat.stop();
  1823.                     updateTimerUserlist.stop();
  1824.  
  1825.                     phpRequest = new URLRequest(userProcessUrl);
  1826.                     phpLoader = new URLLoader();
  1827.        
  1828.                     vars = new URLVariables();
  1829.                     vars.var1 = currentUser;
  1830.                     vars.var2 = "ok";
  1831.                     vars.var3 = "logout";
  1832.                        
  1833.                     phpRequest.data = vars;
  1834.                     phpRequest.method = URLRequestMethod.POST;
  1835.                     phpLoader.load(phpRequest);
  1836.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1837.                    
  1838.                     phpRequest = new URLRequest(chatProcessUrl);
  1839.                     phpLoader = new URLLoader();
  1840.        
  1841.                     vars = new URLVariables();
  1842.                     vars.var1 = currentUser;
  1843.                     vars.var2 = "Leaves @";
  1844.                    
  1845.                     phpRequest.data = vars;
  1846.                     phpRequest.method = URLRequestMethod.POST;                 
  1847.                     phpLoader.load(phpRequest);
  1848.                     phpLoader.addEventListener(Event.COMPLETE, onLogoutComplete);
  1849.                     phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1850.                 }
  1851.             }
  1852.            
  1853.             function onLogoutComplete(event:Event):void
  1854.             {
  1855.                 currentDate = new Date();
  1856.                 userEnter = "logout";
  1857.                 currentUser = "notConnected";
  1858.                
  1859.                 destroyPrivateChatBoxes();
  1860.                 stage.removeChild(emoButton);
  1861.                 stage.removeChild(statusButton);
  1862.                
  1863.                 if(camController.visible == true)
  1864.                 {
  1865.                     camController.killVideoCall();
  1866.                 }
  1867.                
  1868.                 if(userlistContainer && stage.contains(userlistContainer))
  1869.                 {
  1870.                     stage.removeChild(userlistContainer);
  1871.                 }
  1872.                
  1873.                 gotoAndStop("logout");
  1874.                 logout_btn.addEventListener(MouseEvent.CLICK, onLogout);
  1875.                 send_btn.addEventListener(MouseEvent.CLICK, onMessageSendMouseClick);
  1876.                 input_txt.addEventListener(KeyboardEvent.KEY_DOWN, onMessageSendKeyPress);
  1877.             }
  1878.            
  1879.        
  1880. // Scrollbars Mouse Events
  1881. // ***************************************************************************************************************************************
  1882. // ***************************************************************************************************************************************
  1883. // ***************************************************************************************************************************************
  1884.            
  1885.             userscroll_cmp.addEventListener(MouseEvent.MOUSE_OVER, onUserScroll);
  1886.             userscroll_cmp.addEventListener(MouseEvent.MOUSE_DOWN, onUserScroll);
  1887.             userscroll_cmp.addEventListener(MouseEvent.MOUSE_UP, onUserExitScroll);
  1888.             userscroll_cmp.addEventListener(MouseEvent.ROLL_OUT, onUserExitScroll);
  1889.            
  1890.             function onUserScroll(event:MouseEvent):void
  1891.             {
  1892.                 userscroll_cmp.alpha = .6;
  1893.             }
  1894.            
  1895.             function onUserExitScroll(event:MouseEvent):void
  1896.             {
  1897.                 userscroll_cmp.alpha = .0;
  1898.             }
  1899.  
  1900.             function userlistButtonFunctionality(_userlistButton:MovieClip):void
  1901.             {
  1902.                 _userlistButton.userlistButtonClickArea_mc.buttonMode = true;
  1903.                 _userlistButton.userlistButtonClickArea_mc.addEventListener(MouseEvent.MOUSE_DOWN, onUserlistButtonClick);
  1904.                 _userlistButton.userlistButtonClickArea_mc.addEventListener(MouseEvent.MOUSE_OVER, onUserlistButtonOver);
  1905.                 _userlistButton.userlistButtonClickArea_mc.addEventListener(MouseEvent.MOUSE_OUT, onUserlistButtonOut);
  1906.             }
  1907.            
  1908.             function onUserlistButtonClick(event:MouseEvent):void
  1909.             {
  1910.                 if(currentUser != "notConnected")
  1911.                 {
  1912.                     callPrivateChatBox(event.target.parent.username, "none");
  1913.                 }
  1914.             }
  1915.                
  1916.             function onUserlistButtonOver(event:MouseEvent):void
  1917.             {
  1918.                 event.target.parent.gotoAndStop("over");
  1919.             }
  1920.                
  1921.             function onUserlistButtonOut(event:MouseEvent):void
  1922.             {
  1923.                 event.target.parent.gotoAndStop("out");
  1924.             }
  1925.            
  1926.            
  1927.            
  1928.            
  1929.            
  1930.            
  1931.             function addInvitedUser(_userID:String, _username:String)
  1932.             {
  1933.                 camController.userID = _userID;
  1934.                 stage.setChildIndex(camController, stage.numChildren - 1);
  1935.             }
  1936.            
  1937.            
  1938.             function newCamInvitation(_userID:String, _username:String)
  1939.             {
  1940.                 if(camController.callStatus != "active")
  1941.                 {
  1942.                     camController.callStatus = "active";
  1943.                     camController.videoChatStatus = "invited";
  1944.                     camController.chatStatus = "notchatting";              
  1945.                     camController.userID = _userID;
  1946.                     camController.userToInvite = _username;
  1947.                     camController.myUsername = currentUser;
  1948.                     camController.videoCallTitle_txt.htmlText = "<b>Video call with " + _username + "</b>";
  1949.                     camController.visible = true;
  1950.                     camController.reset();
  1951.                     stage.setChildIndex(camController, stage.numChildren - 1);
  1952.                 }
  1953.             }
  1954.            
  1955.             function webCamButtonClick(event:MouseEvent):void
  1956.             {
  1957.                 if(camController.callStatus != "active")
  1958.                 {
  1959.                     camController.callStatus = "active";
  1960.                     camController.videoChatStatus = "starter";
  1961.                     camController.chatStatus = "notchatting";
  1962.                     camController.userToInvite = event.target.parent.username;
  1963.                     camController.myUsername = currentUser;
  1964.                     camController.videoCallTitle_txt.htmlText = "<b>Video call with " + event.target.parent.username + "</b>";
  1965.                     camController.visible = true;
  1966.                     camController.reset();
  1967.                     stage.setChildIndex(camController, stage.numChildren - 1);
  1968.                 }
  1969.             }
  1970.            
  1971.             function sendVideoCallInvitation(event:Event):void
  1972.             {
  1973.                 trace("-> Starting video call: " + camController.myUserID);
  1974.                
  1975.                 phpRequest = new URLRequest(chatProcessUrl);
  1976.                 phpLoader = new URLLoader();
  1977.        
  1978.                 vars = new URLVariables();
  1979.                 vars.var1 = currentUser;
  1980.                 vars.var2 = "/private " + camController.userToInvite + " _cam_" + camController.myUserID;
  1981.  
  1982.                 phpRequest.data = vars;
  1983.                 phpRequest.method = URLRequestMethod.POST;
  1984.        
  1985.                 phpLoader.load(phpRequest);
  1986.                 phpLoader.addEventListener(Event.COMPLETE, onSendPrivateMessageComplete);
  1987.                 phpLoader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);
  1988.             }
  1989.            
  1990.             function closeCamWindow(event:Event):void
  1991.             {
  1992.                 camController.visible = false;
  1993.             }
  1994.            
  1995.            
  1996.            
  1997.            
  1998.            
  1999.            
  2000.            
  2001.            
  2002.            
  2003.            
  2004.            
  2005.            
  2006.            
  2007.            
  2008.  
  2009.  
  2010. // Error Handlers
  2011. // ***************************************************************************************************************************************
  2012. // ***************************************************************************************************************************************
  2013. // ***************************************************************************************************************************************         
  2014.        
  2015.             function ioErrorHandler(event:IOErrorEvent):void
  2016.             {
  2017.                    
  2018.             }
  2019.         }
  2020.     }
  2021. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement