I'm assuming you're using AS 2.0 - inside WeatherManager.as: class WeatherManager {
// private var to hold interval private var weatherTimer; // constructor public function WeatherManager() { weatherTimer = setInterval(mx.utils.Delegate.create(this, changeWeather), 5000); } // weather change func private function changeWeather() { // change the weather } // clear interval func public function cleanUp() { clearInterval(weatherTimer); } } // hope that helps! > I have done as you suggested and have created separate classes for the > balloon, ball, scoreboard and clouds and this all seems to work fine. The > design pattern is based on an Observer pattern where these separate > objects > register themselves as observers of a WeatherManager object. > > I have created a WeatherManager.as class that broadcasts any updates to > the > weather to the observers. > > Now I need to have the WeatherManager periodically change the weather > conditions. I was thinking it should have some sort of internal timer and > every say 5 seconds, it will amend the weather conditions. > > Not sure how best to create an internal timer - would I just use > setInterval > within the WeatherManager class? Or would it be better to create a timer > class and have a loop to continually check this timer? I have had real > problems in the past using setInterval in that they don't seem to clear. > > The game itself is time based and there is a time limit of 80 seconds so > there will need to be a timer for this too. Not sure if best to use just > one > timer for dealing with both or just let the WeatherManager have its own > timer and at the beginning of the game just start its timer and leave it > to > do its updates independently of the main game timer > > Any suggestions most appreciated > > Thanks > > Paul > > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Weyert de > Boer > Sent: 04 November 2006 17:52 > To: Flashcoders mailing list > Subject: Re: [Flashcoders] OOP advice for game > > Yeah, I made a little game myself and use the classes FoodPiece, Snake, > and GameWorld and SnakeGame. Meaning that SnakeGame handles all the > stuff such as start/stop game, score counting. The GameWorld is > responsible for all the drawing, and calling the update method of the > Snake instance, which will then have dedicated code to update itself. > > Works nicely! > > Weyert > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > > _______________________________________________ > Flashcoders@chattyfig.figleaf.com > To change your subscription options or search the archive: > http://chattyfig.figleaf.com/mailman/listinfo/flashcoders > > Brought to you by Fig Leaf Software > Premier Authorized Adobe Consulting and Training > http://www.figleaf.com > http://training.figleaf.com > _______________________________________________ Flashcoders@chattyfig.figleaf.com To change your subscription options or search the archive: http://chattyfig.figleaf.com/mailman/listinfo/flashcoders Brought to you by Fig Leaf Software Premier Authorized Adobe Consulting and Training http://www.figleaf.com http://training.figleaf.com