I'm having 2 problems.
1 - I have a text area in which I am matching a string. If it matches then a timer will start. But that condition will likely be satisfied more than once, so I would like to give a condition that if timer is already running don't do anything, if(!timer.running)
then start timer. But it still resets the timer every time.
2 - I have a chat window. For every user activity a sentence will be displayed to it. For each added sentence I have to perform some actions. So i have given conditions and actions to be performed for each sentence in a single function, but the problem is every time the previous already executed commands are also executed one more time. (for example above problem 1.)so once it matches the 1st string it should start search from 2nd line in the text area, i think this can do the trick. any help will be appreciated.
public function updateMessage(updateMsg:String) : void
{
userActivities.text+=updateMsg+"\n";
if(userActivities.text.indexOf("user connected",0)!=-1)
{
userTimer=new Timer(delay);
if(!userTimer.running)
{
basetmr=getTimer();
userTimer.addEventListener(TimerEvent.TIMER,chkUserActivities);
userTimer.start();
}
else
{
//trace("timerCount.."+userTimer.currentCount);
}
}
else if(userActivities.text.indexOf("user changed the image",0)!=-1 )
{
userActivities.text+="Click ReleaseDetails button to release your details to visitor";
}
else if(userActivities.text.indexOf("user quit the session",0)!=-1)
{
userTimer.stop();
}
}