Use Application.application.unit instead of _root.  Use parseInt to get the number value of your parameter instead of the String.  For the opening do setIsOpen(unitNode, true, false, false) to avoid the animation and then you might be able to get the node correctly.

 

Matt

 


From: [email protected] [mailto:[email protected]] On Behalf Of Kevin Conboy
Sent: Thursday, July 28, 2005 11:26 AM
To: [email protected]
Subject: [flexcoders] Problem with auto-selecting Tree Node

 

Hello, All. I've searched through the email archives and haven't really found anything exactly solving the problem I'm having... Basically, I have a Tree that lists out an e-learning course, with each unit being the root nodes, with their pages living inside of them. What I want is to pass in the query string something like ?unit=1&page=1 in order to have the system pre-select the unit and page you've chosen elsewhere to view.

 

My first problem is that when referring to the variables as _root.unit and _root.page (I'm a flash developer, cut me some slack!) I'm getting the variables fine, except they're typed as String and when I add them together, I get the number 11 (the string "1" concatenated with the string "1" instead of the 1 being added to 1 to get 2).

 

That's my first problem; I'm received query string variables typed incorrectly. My second problem is that even if I skip this step and try and force my tree to open the specified unit (which works), and THEN tell the Tree to set the selectedNode to to the correct node index, it's just pre-selected the root node at that index instead of the node nested in the open unit. Now, when I debug this and actually click the correct node at the correct index, I get back the index I'm setting the selectedNode to, so basically I assume that the selectedNode is being set BEFORE I open the correct unit node, even though I call it after a redraw() after I set the node open. My code is below:

 

     public function selectDefaultUnit(event){

        if(!_root.unit){

            _root.unit = 0;

            }

       if(!_root.page){

            _root.page = 0;

            }    

    

        var unitNode:Object = event.target.getTreeNodeAt(_root.unit);

        event.target.setIsOpen(unitNode,true,true,false);

        event.target.redraw(); // maybe this is unnecessary, but it won't hurt, right?

        

        var pageIndex:Number = _root.unit + _root.page; // this is the code that gets me the strings concatenated with eachother

        var pageNode:Object = event.target.getNodeDisplayedAt(3); // i'm setting 3 here by hand for debugging purposes

        event.target.selectedNode = pageNode;

       

        debugObject(pageIndex,false);// my debug method

               

        event.target.redraw(); // redraws to show the selections. if i don't do this, the tree doesn't show something as being selected until i mouseover it a few times

        }

 

 

Thanks!!!

 

 

........................................................

Kevin Conboy

Lead UI Engineer / Office Dullard

 

SpireMedia®

Inspired Technology. Inspired Results.

 

vox: 303.620.9974 ext 316

fax:  303.629.6385

[EMAIL PROTECTED]

www.spiremedia.com

........................................................





--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to