Re: [Flashcoders] Q:optimizing a Calendar app
Hello :) In my opensource framework when i want create a calendar with appointment i use a Calendar class : http://svn1.cvsdude.com/osflash/vegas/AS2/trunk/src/asgard/date/Calendar.as More information about VEGAS : http://code.google.com/p/vegas/ Install VEGAS : http://code.google.com/p/vegas/wiki/InstallVEGASwithSVN Example to use the Calendar class in the SVN repository : http://svn1.cvsdude.com/osflash/vegas/AS2/trunk/bin/test/asgard/date/ To creates a model of appointment i use my MVC and ADT (Abstract Data Type) implementation with HashMap class. Basic example with an hash map : import vegas.data.map.HashMap ; var map:HashMap = new HashMap() ; var day:Calendar = new Calendar(2007,6,29) ; var appointement:AppointmentVO = new AppointmentVO( day ) ; map.put ( day.valueOf() , appointment ) ; /// ... var app:AppointmentVO = map.get( new Date(2007,6,29).valueOf() ) ; trace( app ) ; PS : My HashMap implementation in AS3 in VEGAS is based over the Dictionnary class. EKA+ :) 2007/7/29, Steven Sacks [EMAIL PROTECTED]: Apologies for not being clearer. I did not intend for you to use new Date().getTime() literally. What I meant was events[new Date(year, month, day).getTime()] so you could use the calendar date itself as the key. It makes no difference what key you decide to use, as long as the key is easy to look up because it has relevance to the calendar date. It's probably less expensive to do [month + / + day + / + year] than creating a new Date object. And yes, in AS3, this would be a good candidate for a Dictionary object. Steven Sacks Flash Maestro Los Angeles, CA -- blog: http://www.stevensacks.net ___ 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] Q:optimizing a Calendar app
Hi I have a simple Calendar class which creates a new month display when the application first loads and each time the user changes the month. I need to add appointments on specific days for each month. I have an appointment array, which contains a list of date strings in the format 'month/day/year'. Now to add appointment icons or objects, I iterate thru every day in the current month, then for each day, I iterate thru this appointment array to see if there is a match to one of these date strings. It seems to me there must be a less computationally expennsive way to add appointments to a calenndar, than the way I've described. Or am I wrong? [e] jbach at bitstream.ca [c] 416.668.0034 [w] www.bitstream.ca ...all improvisation is life in search of a style. - Bruce Mau,'LifeStyle' ___ 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
Re: [Flashcoders] Q:optimizing a Calendar app
That is a very expensive way to do it. You should, instead, make a hash and the keys would be the date, and the values would be an array of appointments for that date. events = {}; events[month + / + day + / + year] = []; events[month + / + day + / + year].push(appointment); Then each day of the calendar would just do a look up of itself in the hash. events[calendarDate]; You could also store the key as a new Date().getTime() instead of a string with month/day/year. It's entirely up to you. HTH! Steven Sacks Flash Maestro Los Angeles, CA -- blog: http://www.stevensacks.net ___ 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
RE: [Flashcoders] Q:optimizing a Calendar app
Using getTime() isn't ideal since that's creating a timestamp based on milliseconds, which would be unique. The first option is probably the safer bet to be able to index things by a specific date (as opposed to a time). If you're using AS3, then I'd say use a Dictionary object (same as a hash, except you're not using a generic Object). -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Steven Sacks Sent: Sunday, July 29, 2007 12:42 AM To: flashcoders@chattyfig.figleaf.com Subject: Re: [Flashcoders] Q:optimizing a Calendar app That is a very expensive way to do it. You should, instead, make a hash and the keys would be the date, and the values would be an array of appointments for that date. events = {}; events[month + / + day + / + year] = []; events[month + / + day + / + year].push(appointment); Then each day of the calendar would just do a look up of itself in the hash. events[calendarDate]; You could also store the key as a new Date().getTime() instead of a string with month/day/year. It's entirely up to you. HTH! Steven Sacks Flash Maestro Los Angeles, CA -- blog: http://www.stevensacks.net ___ 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