Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-20-2007, 12:27 AM   #1
grouchy
Registered User
 
Join Date: Mar 2007
Posts: 13
Default xml tree conundrum/problem

Hello Everyone. I am an actionscript amateur and need some help in a problem.

Basically i need to attach a comment to an tree node. so that when the tree node is selected and the user types in some comment in a text area and presses the 'submit comment' button. their comment is saved against a tree node. Thus when a user selects that tree node then their comment is displayed (possibly in that text area).

- I have imported an XML file into flash and used the 'TREE' component to display it.

- I have created a text area - the user would type in some sort of comment in there.

- After comment is written when they press a button ("SUBMIT COMMENT") i need that comment to be saved against a tree node.

- Thus when a user clicks on that tree node their comment is displayed.

Do i need to store the comment as a variable? any help or pointers greatly appreciated.

Many thanks for your efforts.
grouchy is offline   Reply With Quote
Old 03-20-2007, 03:43 AM   #2
EdKav1
Registered User
 
Join Date: Apr 2005
Location: Durham, NC
Posts: 305
Default

You can add the comments as properties of the items in the tree. Use getSelectedItem() to get a reference to the item currently selected in the tree.

For example if your TextArea had an instance name of "myTA", your tree "myTree" and your submit button "myButton" you could set up listeners using something like:

ActionScript Code:
//listener object for tree var lo:Object = new Object(); lo.change = function(evtObj:Object):Void{     var itm:Object = myTree.getSelectedItem();     if(itm.savedComment != undefined)         myTA.text = itm.savedComment;     else         myTA.text = ""; } myTree.addEventListener("change",lo); //listener object for submit button var lo2:Object = new Object(); lo2.click = function(evtObj:Object):Void{     var itm:Object = myTree.getSelectedItem();     itm.savedComment = myTA.text; } myButton.addEventListener("click",lo2);

In this case I set a property named "savedComment" to store the entered comments.


Best of luck,

Ed
EdKav1 is offline   Reply With Quote
Old 03-23-2007, 01:21 AM   #3
grouchy
Registered User
 
Join Date: Mar 2007
Posts: 13
Default attaching comment to XML

Hello Ed, and every1 else.

Can i first say a big thank you for your effort, you didnt have to and i really appreciate it...im somewhat of a novice and am finding my feet.

I can now attach a comment to a node. Prior to that I have imported my xml file - which contains the tree into flash and can now display the tree structure and all of its nodes. the comment is there so thats great.

Is there any way though that you can update the xml file with the comment that you have submitted.

i.e. after you have attached the comment with a node, is there any way that the comment willl be passed through to that xml file itself?

Im thinking i need an attribute in the xml file called say "comment" and somehow when you press the submit button to attach the comment to a node the xml file (the "comment" attribute within) is also updated with the comment.
grouchy is offline   Reply With Quote
Old 03-25-2007, 12:22 AM   #4
grouchy
Registered User
 
Join Date: Mar 2007
Posts: 13
Default

hi ED,

is there any chance you could very briefly explain what your fantastic code does. am i right in saying that it is listening for a user to select a node then if a user enters that comment in the text area then that is what is stored against the node otherwise nothing is stored against the node.

thanks v.much
grouchy is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Detect a broken XML from server - please help in a stupid man suit ActionScript 2.0 0 03-12-2007 03:27 PM
Tree Component with MediaPlayback and XML jschutt Components 0 02-21-2007 08:41 PM
releasing xml file from XML.onLoad() sophistikat ActionScript 2.0 2 02-21-2007 07:00 PM
Tree, 8 Pro: lines disappear after http refresh vaynerm Components 0 01-05-2006 04:38 PM
Tree Component crashes, Help! rtnews0423 Components 1 12-29-2004 07:10 PM


All times are GMT. The time now is 05:06 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.