# Flash (MX or 8) with XML generated menu (have a problem)

**URL:** <https://forum.kirupa.com/t/flash-mx-or-8-with-xml-generated-menu-have-a-problem/184451>\
**Category:** programming\
**Created:** [April 5, 2006, 7:35am UTC](https://forum.kirupa.com/t/flash-mx-or-8-with-xml-generated-menu-have-a-problem/184451 "2006-04-05T07:35:45Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![goldenshower](https://avatars.discourse-cdn.com/v4/letter/g/a3d4f5/32.png) [@goldenshower](https://forum.kirupa.com/u/goldenshower)\
**Post date:** [April 5, 2006, 7:35am UTC](https://forum.kirupa.com/t/flash-mx-or-8-with-xml-generated-menu-have-a-problem/184451/1 "2006-04-05T07:35:45Z")

</div>

Hi I have downloaded an XML/Flash Menu, and customized it a bit and it works great, but i want to add some more functionality, (unfortunaly its way over my head, im just a lowlevel flasher on the script side, and XML is quite new to me, very very insteresting though and its gonna be my next thing to really explore) 🙂

1:  
HOW is it possible to add functionality to the XML so it will act just like  
\_root\_gotoAndStop(“lable1”); would do in flash?  
meaning i want to add function to the links in the XML so it can jump to a frame or frameLable i flash via the XML input…

My flash file is 1 file, 5 frames (with stop(); actions (each frame 1 menu point) - and no serious scripting the one “special” thing is a news section  
which load content fra an XML file. there on LoadMovies or anything that might complicate things.

2: I also want to ad a simple getURL function to the XML  
(this could actually be fixed just witha frameaction inside flash IF question 1 i possible) basically i just want a link to work as the getURL(url [, window [, “variables”]])

anyway the MAIN question is HOW do i add the gotoAndPlay function in the script pasted here below:

(as said my AS and XML is quite pathetic so be gentle) 🙂

* * *

**HERE THE FLASH CODE:**

**FRAME1** Code In flash:

import it.sephiroth.TreeDnd

// set some style to the component  
var theTree:mx.controls.Tree = dnd.getTree();  
theTree.setStyle(‘fontFamily’,‘font1’)  
theTree.setStyle(‘fontSize’,8);  
theTree.setStyle(‘embedFonts’, true);  
theTree.setStyle(‘backgroundColor’,‘0xFFFFFF’);  
theTree.setStyle(‘rollOverColor’,‘0xE9E9F3’);  
theTree.setStyle(‘selectionColor’,‘0xBCCCDF’);  
theTree.setStyle(‘textSelectedColor’,‘0xFFFFFF’);  
theTree.setStyle(‘openDuration’, 100);  
theTree.setStyle(‘selectionDuration’,0);  
theTree.setStyle(“disclosureClosedIcon”, “iconPlus”)  
theTree.setStyle (“disclosureOpenIcon”,“iconMinus”);  
dnd.setStyle(“separatorColor”, ‘0xFF0000’);  
theTree.rowHeight = 20;  
theTree.vScrollPolicy = “auto”  
theTree.iconFunction = function(item){  
if( this.getIsBranch(item)){  
return “folder\_icon”  
} else {  
return “node\_icon”  
}  
}

// define event listener  
var dndList:Object = new Object();  
dndList.double\_click = function(evt:Object)  
{  
testo.text = evt.type  
}  
dndList.drag\_start = function(evt:Object)  
{  
testo.text = evt.type  
}  
dndList.drag\_fail = function(evt:Object)  
{  
testo.text = evt.type  
}  
dndList.drag\_complete = function(evt:Object)  
{  
trace(‘drag complete’)  
testo.text = evt.type  
}  
dndList.drag\_target = function(evt:Object)  
{  
trace(‘drag\_target’)  
evt.targetMc.text = "Dropped: " + evt.sourceNode  
}  
// \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
// set the event listeners  
// \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
this.dnd.addEventListener(‘double\_click’, dndList);  
this.dnd.addEventListener(‘drag\_start’, dndList);  
this.dnd.addEventListener(‘drag\_fail’, dndList);  
this.dnd.addEventListener(‘drag\_complete’, dndList);  
this.dnd.addEventListener(‘drag\_target’, dndList); // when an item is dropped over a defined target

this.dnd.dropTarget = [testo] // defined a drop target

/\*\*  
you can define also custom drag and drop functions

this.dnd.dragFunction = function(item:XMLNode){  
// return if item can be dragged  
return true;  
}

this.dnd.dropFunction = function(source:XMLNode, target:XMLNode){  
// return if dragged item can be dropped into the target item  
return true  
}

\*\*/

// \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
// Now load an XML into Tree component  
// \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
var \_xml:XML = new XML();  
\_xml.ignoreWhite = true  
\_xml.onLoad = function(){  
dnd.getTree().dataProvider = this.firstChild  
}  
\_xml.load(“example.xml”);

**FRAME1 Code (different layer) In Flash:**

import it.sephiroth.TreeDnd

var check\_listener:Object = new Object();  
check\_listener.click = function(evt:Object){  
var data:String = evt.target.label  
var obj\_string:Number = 0  
if( data == ‘DEFAULT’ or data == ‘DENYALL’)  
{  
for(var a = 0; a \< 6; a++)  
{  
if( evt.target._parent['cb_’ + a] != evt.target)  
{  
evt.target._parent['cb_’ + a].selected = false  
}  
}  
} else {  
evt.target.\_parent.cb\_0.selected = false  
evt.target.\_parent.cb\_1.selected = false  
}  
for(var a = 0; a \< 6; a++){  
if( evt.target._parent['cb_’ + a].selected == true){  
obj\_string |= TreeDnd[evt.target._parent['cb_’ + a].label]  
}  
}  
trace(obj\_string)  
evt.target.\_parent.dnd.dragRules = obj\_string  
trace( evt.target.\_parent.dnd.dragRules )  
}

this.cb\_0.addEventListener(‘click’, check\_listener);  
this.cb\_1.addEventListener(‘click’, check\_listener);  
this.cb\_2.addEventListener(‘click’, check\_listener);  
this.cb\_3.addEventListener(‘click’, check\_listener);  
this.cb\_4.addEventListener(‘click’, check\_listener);  
this.cb\_5.addEventListener(‘click’, check\_listener);

for(var a = 0;a \< 6; a++){  
this[‘cb\_’ + a].setStyle(‘fontFamily’,‘font1’)  
this[‘cb\_’ + a].setStyle(‘fontSize’,8);  
this[‘cb\_’ + a].setStyle(‘embedFonts’, true);  
}

testo.setStyle(‘fontFamily’,‘font1’)  
testo.setStyle(‘fontSize’,8);  
testo.setStyle(‘embedFonts’, true);

* * *

**And here is the XML:**

## \<?xml version=“1.0” encoding=“iso-8859-1”?\> \<node data=“id=1” label=“Welcome - website” icon=“folderYellowClosed”\> \<node isOpen="" data=“id=233” label=“HOVEDMENU1”\> \<node data=“id=245” label=“SUB1\_0”/\> \<node data=“id=245” label=“SUB1\_1”/\> \<node data=“id=245” label=“SUB1\_2”/\> \<node data=“id=245” label=“SUB1\_3”/\> \<node data=“id=245” label=“SUB1\_4”/\> \</node\> \<node isOpen="" data=“id=305” label=“HOVEDMENU2”\> \<node data=“id=621” label=“SUB2\_1”/\> \<node data=“id=625” label=“CSUB2\_2”/\> \<node data=“id=621” label=“SUB2\_3”/\> \<node data=“id=625” label=“SUB2\_4”/\> \<node data=“id=625” label=“SUB2\_5”/\> \<node data=“id=621” label=“SUB2\_6”/\> \<node data=“id=625” label=“SUB2\_7”/\> \</node\> \<node isOpen="" data=“id=325” label=“HOVEDMENU3”\> \<node data=“id=329” label=“SUB3\_1”/\> \<node data=“id=333” label=“SUB3\_2”/\> \<node data=“id=337” label=“SUB3\_3”/\> \</node\> \<node isOpen="" data=“id=369” label=“HOVEDMENU4”\> \<node data=“id=373” label=“SUB4\_1”/\> \<node data=“id=377” label=“SUB4\_1”/\> \</node\>

please please 🙂  
i have tried downloading dozens of flash/xml files to learn more but i have not been able to overcome this issue)
