A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: Best way to do this...db & tree component

  1. #1
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929

    Best way to do this...db & tree component

    I've got a tree component on the stage that the user can add folders and questions to. I need to write the data from the tree into a database as the user adds items and then re-build the tree from the database when the user re-opens the program. This works fine except the client wants the user to be able to delete and move items within the tree.

    I'm not sure how I can track the position of items within the tree so that it re-builds the tree (from the database values) in the same order as it was when the user closed the program?

    At first, I thought I would just add the getDisplayIndex of the selectedNode, but that changes when you expand or collapse a folder, and it would also mean that I would have to update a number in each database entry any time the user moves a folder or item...

    Does that make sense??

    It's making my head hurt...
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

  2. #2
    anyone else hear that? flashpipe1's Avatar
    Join Date
    Jan 2003
    Location
    Upstate NY
    Posts
    1,929

    Got It!!

    I think I finally got it working. Not sure it's the best way, but here's what I did (in case anyone else runs into this)...

    When the user adds, removes or re-arranges items in the tree, those changes are just made in the tree nodes (still no databinding to xml), and items are added & removed from the arrays.

    I added a "Save" button, and when the user clicks it, the old database is copied over with an empty version, and then I use a while loop to go through each node in the tree, test the node label against each item in each array, and when it finds a match, it writes that entry to the database...

    This seems to work, builds the database properly and then I just parse through the db to re-build the tree when the user starts the program again...

    Not sure if I'm going to run into speed issues when we get lots of entries, but we'll find out soon!!

    Thanks for the input!!!
    Love like you've never been hurt, live like there's no tomorrow and dance like nobody's watching.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center