is right? its not working....
Code:
/*
*************************************
Shout Box
http://www.FlepStudio.org
© Author: Filippo Lughi
version 1.0
*************************************
*/
package org.flepstudio.shoutbox
{
import flash.display.MovieClip;
import flash.display.SimpleButton;
import flash.text.TextField;
import fl.controls.UIScrollBar;
import flash.text.StyleSheet;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.events.ContextMenuEvent;
import flash.net.URLRequest;
import flash.net.URLLoader;
import flash.net.navigateToURL;
import flash.ui.ContextMenu;
import flash.ui.ContextMenuItem;
import org.flepstudio.shoutbox.LoadingXML;
import org.flepstudio.shoutbox.Store;
import org.flepstudio.shoutbox.SendTheMessage;
import flash.utils.Timer;
import flash.events.TimerEvent;
public class Main extends MovieClip
{
private var _css:StyleSheet;
private var file_xml:LoadingXML;
private var _Name:String;
private var _Message:String;
private var scroller:UIScrollBar;
private var counter:int;
public function Main()
{
initMenu();
init();
loadCSS();
initTimer();
}
private function init():void
{
stage.frameRate=31;
}
private function loadCSS():void
{
var loader:URLLoader=new URLLoader();
var request:URLRequest=new URLRequest();
request.url='http://www.dreameiken.com/ShoutBox/style.css';
loader.addEventListener(Event.COMPLETE,onCSS);
loader.load(request);
}
private function onCSS(evt:Event):void
{
_css=new StyleSheet();
_css.parseCSS(evt.target.data);
loadXML();
shoutbox_mc.shoutbox_txt.styleSheet=_css;
shoutbox_mc.shoutbox_txt.wordWrap=true;
}
private function loadXML():void
{
file_xml=new LoadingXML(this);
}
public function displayShoutBox():void
{
stopTrace();
var s:String='';
for(var i:int=0;i<Store.datas_array.length;i++)
{
//var myPatternSmile:RegExp=/:\)/g;
//var myPatternSad:RegExp=/:\(/g;
var date:String='<a class="date"> '+(Store.datas_array[i])+' </a>'+'\n';
s+=date;
var name_:String='<a class="name"> '+(Store.names_array[i])+' </a>'+' says:'+'\n';
s+=name_;
var mess:String='<a class="shout"> '+(Store.messages_array[i])+' </a>'+'\n';
//var smile:String=mess.replace(myPatternSmile,"smilie");
//var smile:String=mess.replace(myPatternSmile,"<img align='left' src='http://www.flepstudio.org/utilita/ShoutBox/emoticons/smile.gif'/>");
//var sad:String=smile.replace(myPatternSad,"sad");
s+=mess;
}
shoutbox_mc.shoutbox_txt.htmlText=s+'\n';
scroller=new UIScrollBar();
scroller.setSize(shoutbox_mc.shoutbox_txt.width,290);
scroller.move(200,10);
scroller.scrollTarget=shoutbox_mc.shoutbox_txt;
addChild(scroller);
addButtonListener();
}
private function addButtonListener():void
{
shout_btn.addEventListener(MouseEvent.MOUSE_DOWN,checkForm);
}
private function checkForm(evt:MouseEvent):void
{
var n:String=name_txt.text;
var m:String=message_txt.text;
if(n.length>=3&&m.length>=2)
{
_Name=n;
_Message=m;
shout_btn.removeEventListener(MouseEvent.MOUSE_DOWN,checkForm);
removeChild(scroller);
shoutbox_mc.shoutbox_txt.text='';
name_txt.text='';
message_txt.text='';
traceWriting();
var send_the_message:SendTheMessage=new SendTheMessage(_Name,'noMail@noMail.noMail',_Message,this);
}
}
private function traceWriting():void
{
counter=0;
shoutbox_mc.addEventListener(Event.ENTER_FRAME,go);
}
private function go(evt:Event):void
{
counter++;
if(!(counter%5))
evt.target.shoutbox_txt.text='';
else
evt.target.shoutbox_txt.text='writing';
}
private function stopTrace():void
{
shoutbox_mc.removeEventListener(Event.ENTER_FRAME,go);
}
public function refreshShoutBox():void
{
Store.datas_array=new Array();
Store.names_array=new Array();
Store.messages_array=new Array();
loadXML();
}
public function initMenu():void
{
var etichetta:String="***Flash CS3 ShoutBox by FlepStudio***";
var cm:ContextMenu=new ContextMenu();
var item:ContextMenuItem=new ContextMenuItem(etichetta);
cm.hideBuiltInItems();
cm.customItems.push(item);
item.addEventListener(ContextMenuEvent.MENU_ITEM_SELECT,itemHandler1);
this.contextMenu=cm;
}
private function itemHandler1(event:ContextMenuEvent):void
{
var url:String='http://www.flepstudio.org/';
var request:URLRequest=new URLRequest(url);
navigateToURL(request,'_parent');
}
private function initTimer():void
{
timer=new Timer(5000,0);
timer.addEventListener(TimerEvent.TIMER,refreshWithTimer);
timer.start();
}
private function refreshWithTimer(evt:TimerEvent):void
{
trace('ok');
Store.datas_array=new Array();
Store.names_array=new Array();
Store.messages_array=new Array();
loadXML();
}
}
}