Forum ActionScript 3.0 Using Timers

Problems and discussions relating to ActionScript 3.0 here.

Using Timers

Postby Turrican » February 6th, 2012, 6:11 pm

Hello!
My game has 3 clock's and all of them are controlled by the Flash client.
I want to make the control by the server, and I'm trying to use the AddTimer event.
I read the instructions but I didn'd understand... :(

So, what I'm doing:

At first, this is a message sent from the game:
Code: Select all
                case "startJogo":
                    {
                        int nada = message.GetInt(0);
                        tempoTotal();
                        break;
                    }




After I receive this message, I call the tempoTotal() function:
Code: Select all
        private void tempoTotal()
        {
           AddTimer(delegate{mandaTempo();},166);
        }


And at last, I send a Broadcast:
Code: Select all
        private void mandaTempo()
        {
                Broadcast("tempoTotal", 1);
        }


But nothing happens.

PS: will this ensure that all the clients will have the same clock time?
Turrican
 
Posts: 23
Joined: August 11th, 2011, 11:50 pm

Re: Using Timers

Postby khanahmed_95@hotmail.com » April 29th, 2012, 5:16 am

im not really sure but i don't think u need the delegate.

so instead of this
AddTimer(delegate{mandaTempo();},166);

write
AddTimer(mendaTempo, 166);

or

AddTimer(delegate {
// code here will run every 166 millisecond
}, 166);

hope it helped :D
khanahmed_95@hotmail.com
 
Posts: 9
Joined: November 21st, 2011, 3:07 am

Re: Using Timers

Postby Turrican » April 30th, 2012, 6:48 pm

khanahmed_95@hotmail.com wrote:im not really sure but i don't think u need the delegate.

so instead of this
AddTimer(delegate{mandaTempo();},166);

write
AddTimer(mendaTempo, 166);

or

AddTimer(delegate {
// code here will run every 166 millisecond
}, 166);

hope it helped :D



I´ll try that!
Thanks a lot! :D
Turrican
 
Posts: 23
Joined: August 11th, 2011, 11:50 pm


Return to ActionScript 3.0



cron