From: adnanyaseen1 on
Hi, I am new in using Flash Components in Director. I have seen that there is
not a lot of documentation or Help available on How to use Flash components in
Director MX effectively. The problem that i have been facing is with Tree
component. I have populated the tree which is on sprite 1 with the following
code,

if voidP(pSprite) then

pSprite = sprite(me.spriteNum)

tNewNode_Main = sprite(1).addTreeNode("Main Menu")
pSprite.setIsBranch(tNewNode_Main,TRUE)

-- Sub-Level Node
tNewLeaf_Main_sub = tNewNode_Main.addTreeNode("Sub-Menu")
pSprite.setIsBranch(tNewLeaf_Main_sub,TRUE)

-- Add a Sub-Level Leaf
tNewLeaf_Main_sub_link1 = tNewLeaf_Main_sub.addTreeNode("Link 1")
tNewLeaf_Main_sub_link1 = tNewLeaf_Main_sub.addTreeNode("Link 2")
tNewLeaf_Main_sub_link1 = tNewLeaf_Main_sub.addTreeNode("Link 3")

end if
end

The Problem is that i want that when i expand the Tree and click on the Link
"Link 1" then it should go the marker named "My_Link". But i dont exactly how
to do this. I would appreciate if anyone can guide me through.

Regards.

From: Darrel Hoffman on
> Hi, I am new in using Flash Components in Director. I have seen that there
> is
> not a lot of documentation or Help available on How to use Flash
> components in
> Director MX effectively.

I can't help directly with this problem, but my advice in general is to
avoid using Flash Components unless you're an experienced Flash user. I can
recreate most of them from scratch quicker than I can figure out how to make
them behave properly. E.g.: I used to use the Flash Component Buttons,
which were the only one I could figure out how to make respond correctly to
inputs. Then I discovered that their mere presence on the stage intercepted
all keyboard input and prevented Director from even seeing that keys were
being pressed. Replaced all the Flash buttons with either Director-standard
buttons (comparatively dull and flat, but functional) or my own custom
graphics (which I usually do anyhow), and it works perfectly.

The documentation exists, by the way, but it's not in Director - it's in
Flash. If you have any relatively recent version of Flash, you might be
able to figure something out by looking at the documentation for that, but I
still think it's just easier to avoid using them altogether. They seem to
have been included in Director specifically to be used by people who also
know Flash, and if you don't, they're not about to help you figure it out
unless you also purchase that program.


From: CenturyMan1979 on
set up a behavior script attached the the tree component and attach the code I
have added to this message, now when you select ( not when you click arrow to
open a branch ) a folder or file you will get the label of the item selected in
the message window. Now you should be able to take that info and create a case
statement that you can use to navigate your application.

Also just a note, you can add a data item when you add a tree node like so,
addTreeNode("Label", "Data") .Then you can access the data like you do the
label in the code I provided except you just use the word data instead of label.




on change(me)
set pSprite = sprite(me.spriteNum)
put pSprite.selectedNode.attributes.label
end change

From: stephen_ on
Something like this;




property pSprite
property pListener

on exitFrame me

if voidP( pSprite ) then

pSprite = sprite( me.spriteNum )

tNewNode_Main = pSprite.addTreeNode( "Main Menu" )
pSprite.setIsBranch( tNewNode_Main, TRUE )

tNewLeaf_Main_sub = tNewNode_Main.addTreeNode( "Sub-Menu" )
pSprite.setIsBranch( tNewLeaf_Main_sub,TRUE )

tNewLeaf_Main_sub_link1 = tNewLeaf_Main_sub.addTreeNode( "Link 1" )
tNewLeaf_Main_sub_link1.nodeName = "Link"
tNewLeaf_Main_sub_link1 = tNewLeaf_Main_sub.addTreeNode( "Link 2" )
tNewLeaf_Main_sub_link1.nodeName = "Link"
tNewLeaf_Main_sub_link1 = tNewLeaf_Main_sub.addTreeNode( "Link 3" )
tNewLeaf_Main_sub_link1.nodeName = "Link"

pListener = pSprite.newObject( "Object" )
pSprite.setCallBack( pListener, "change", #change, me )

pSprite.addEventListener( "change", pListener )

pSprite.selectedNode = tNewNode_Main
end if

end exitFrame

on change me
if NOT ( ilk( pSprite ) = #sprite ) then
exit
end if

v_node = pSprite.selectedNode

if NOT ( v_node.nodeName = "Link" ) then
exit
end if

v_link = v_node.attributes.label

pSprite = VOID
pListener = VOID

_movie.go( v_link )

end change