Battletech Live

Online, Turn-Based Battletech – Development Logs

Mail composition, adding / removing folders and moving messages

I’m working on a number of things right now and my hosting provider appears to be having an outage.  So, since I can’t update anything on the server, I thought I’d post an update here.  When I first think about setting up a mail system to handle simple text-based messages, it doesn’t seem like it should be all that complicated.  But when I dig deeper into the process, there’s a surprising amount of work that goes into a system.  Right now, the email system works.  I can compose messages, select who to send them to and they go.  I don’t have it enabled for anyone else yet because I still have a number of bugs and some features that don’t work quite right yet.  For instance, moving a message from one folder to another or just deleting messages.  Those are the two biggest things I’m working on right now, or at least I was until my server stopped responding.

When an email message is retrieved, you’d expect that you need to know who it’s from, who it’s to, it’s subject and it’s content.  Those four basic things let you view messages that were sent to or were sent by you.  A number of other things also need to be known, such as which folder the message is supposed to be in and the position at which the message lives on the server.  These two things are important because if you move a message from the inbox to a saved folder, the application need to know the index for where the message was and the index for where it is being moved to so that the server can be updated.  The index of the message itself lets the application simply say message 24 instead of having to search the mail server for the correct message.

So that’s how moving messages works.  The other complicated thing is the actual folder list. Each Battletech Live member has their own folder set.  Everyone has the same basic set of folders shown below.  These folders can’t be deleted, but they can be repositioned.  Members can create new folders that live among and within their basic folders.  If a user wants to keep saved items from a number of people but wants a little more organization, they can create folders inside Saved Items to store messages from specific individuals.  The trick is how to set this system up so that it’s easy to use and requires as little direction as possible.  In most email systems, if you want to move a message, you simply drag the message from the message list onto the folder you want to put it in.  That’s all well and good, but the default drag-and-drop system for Actionscript 3 wants to drop the message among the folder list.  It doesn’t know that you want it to go into the selected item and there’s no automatic way of getting this to work.  I can get it to highlight the folder that the mouse is hovering over but it still puts a line above or below, indicating where the message will be dropped.  So, at present, when a message is selected, a button becomes active, which then brings up a panel that allows the user to select the folder they want to put the message in.  Clicking Confirm, then submits the information back to the server so that it’s positioning can be updated, or at least it would if the server hadn’t gone down.  Later on, I will be building a custom component that will accurately set up the drag-and-drop system so that messages go into the specified folder instead of among the existing folders.  When that function is done, the Move button will be deleted, no longer serving a purpose.

picture-11

Adding and deleting folders.  For a while, I struggled with how to set up the folders and how to get them to display correctly.  I started out with four pieces of information on the server:

  1. The name of the individual folder.
  2. The owner of that folder.
  3. The folders parent, if any.
  4. The position at which the folder should be displayed.

When I started setting it up, I displayed the information in a DataGrid, which I soon realized was the wrong approach.  Since folders can have children as well as siblings, a Tree component was really what I needed.  I started looking up ways to build the tree structure programatically and found that it seems much easier to build the structure of the tree as XML and link it.  Every five minutes, or whenever the member pushes something to the server, it checks new mail and updates the folder structure.  For each folder, it retrieves the four pieces of information above and decides how it should be assembled.  The resulting structre is then assigned to an XML variable which the tree then uses as a DataProvider.  I will be looking into how to set the icon of each item in the XML structure so that Inbox can be visually different from Deleted Items, Sent Items and so on.  Adding folders will be similar to moving messages.  The member clicks Add at the bottom of the list and it asks them to name the new folder and select the folder in which it should reside.  Clicking Confirm will push the updated data back to the server.  Removing folders works the same way.  In the end, I will have context menus set up so that members can right-click an existing folder and click New Folder or Delete Folder, if they should so choose.

Advertisements

April 4, 2009 - Posted by | Project Development

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: