Groups | Blog | Home
all groups > flash actionscript > january 2007 >

flash actionscript : ActionScript SubMenu



72dolphins
1/31/2007 10:27:19 PM
Hello-
I have received a Flash file that contains some ActionScript I cannot
decipher. In a nutshell, there is a navigation menu whose content and links are
loaded via an XML document. To see the menu in question, view this link:
http://www.itsonmessage.com/folio/portfolio.html

You can see the menu I am referring to on the left. Essentially, I am trying
to add another link below the ones that are currently there. But, whenever I
add the new link into the XML file, the Flash movie does not display it. I am
at a loss on how to fix this... Could anyone suggest what could be going on?

For reference, the following is both the XML code and the code that is in the
Flash file for loading the XML. Thanks in advance.

XML:
<?xml version="1.0"?>

<menu>
<item name="identities">
<sub name="/brand" action="brand.swf">
</sub>
<sub name="/event" action="event.swf">
</sub>
</item>
<item name="print ads" action="print_ads.swf">
</item>
<item name="collateral" action="collateral.swf">
</item>
<item name="direct mail" action="direct_mail.swf">
</item>
<item name="web/interactive" action="web.swf"/>
</item>
<item name="integrated branding" action="integrated_branding.swf"/>
</item>
</menu>

Actionscript:
stop();
var contentFile = "xmlFiles/menuContent.xml";
var configFile = "xmlFiles/menuConfig.xml";
contentXML = new XML();
configXML = new XML();
contentXML.varTarget = this;
configXML.ignoreWhite = contentXML.ignoreWhite = true;
contentXML.onLoad = function (success)
{
if (success)
{
var vt = this.varTarget;
var root = this.firstChild;
vt.menuObj = new Object();
var i, j, k, m, h, a;

(i = root.lastChild, j = 1);
while (i != null)
{
vt.menuObj["item" + j] = new Object();
vt.menuObj["item" + j].name = i.attributes.name;
vt.menuObj["item" + j].age = i.attributes.age;
vt.menuObj["item" + j].location = i.attributes.location;
vt.menuObj["item" + j].action = typeof(i.attributes.action) == "undefined"
? null : i.attributes.action;
vt.menuObj["item" + j].sub = false;
if (i.hasChildNodes())
{
vt.menuObj["item" + j].sub = true;
(k = i.lastChild, m = 1);
while (k != null)
{
vt.menuObj["item" + j]["sub" + m] = new Object();
vt.menuObj["item" + j]["sub" + m].name = k.attributes.name;
vt.menuObj["item" + j]["sub" + m].age = k.attributes.age;
vt.menuObj["item" + j]["sub" + m].location = k.attributes.location;
vt.menuObj["item" + j]["sub" + m].action = typeof(k.attributes.action) ==
"undefined" ? null : k.attributes.action;
vt.menuObj["item" + j]["sub" + m].subsub = false;
if (k.hasChildNodes())
{
vt.menuObj["item" + j]["sub" + m].subsub = true;
(h = k.lastChild, a = 1);
while (h != null)
{
vt.menuObj["item" + j]["sub" + m]["subsub" + a] = new Object();
vt.menuObj["item" + j]["sub" + m]["subsub" + a].name =
h.attributes.name;
vt.menuObj["item" + j]["sub" + m]["subsub" + a].age = h.attributes.age;
vt.menuObj["item" + j]["sub" + m]["subsub" + a].location =
h.attributes.location;
vt.menuObj["item" + j]["sub" + m]["subsub" + a].action =
h.attributes.action;
(h = h.previousSibling);
a++;
}
vt.menuObj["item" + j]["sub" + m].Number_SubSubs = a - 1;
}
(k = k.previousSibling);
m++;
}
vt.menuObj["item" + j].Number_Subs = m - 1;
}
(i = i.previousSibling);
j++;
}
_global.Number_Items = j - 1;
vt.play();
}
else
{
trace("ERROR PARSING XML");
}
};
function loadContent()
{
contentXML.load(contentFile);
}
configXML.onLoad = function (success)
{
if (success)
{
var root = this.firstChild;
configObj = new Object();
configObj.menuSpeed = root.attributes.menuSpeed;
configObj.menuSpacer = root.attributes.menuSpacer;
configObj.colorSpeed = root.attributes.colorSpeed;
allLevels = root.childNodes;
for(var i=0; i<allLevels.length; i++)
{
configObj[allLevels[i].nodeName] = new Object;
configObj[allLevels[i].nodeName].overColor =
allLevels[i].attributes.overColor;
configObj[allLevels[i].nodeName].outColor =
allLevels[i].attributes.outColor;
configObj[allLevels[i].nodeName].delay = allLevels[i].attributes.delay;
}
loadContent();
}
else
{
trace("ERROR PARSING XML");
}
}
configXML.load(configFile);
SymTsb
2/1/2007 6:02:47 PM
sergioch
2/1/2007 6:09:55 PM
72dolphins
2/2/2007 2:03:57 AM
Here are the comtents of the two XML files:

MenuConfig.xml
<?xml version="1.0"?>

<menuConfig menuSpeed="3" menuSpacer="15" colorSpeed="3">

<item OverColor="0x000000" outColor="0xFF9900" delay="100"/>

<sub OverColor="0x333333" outColor="0x00CCCC" delay="170"/>

<subsub OverColor="0x66FF99" outColor="0x66CC99" delay="170"/>

</menuConfig>

MenuContent.xml
<?xml version="1.0"?>

<menu>
<item name="identities">
<sub name="/brand" action="brand.swf">
</sub>
<sub name="/event" action="event.swf">
</sub>
</item>
<item name="print ads" action="print_ads.swf">
</item>
<item name="collateral" action="collateral.swf">
</item>
<item name="direct mail" action="direct_mail.swf">
</item>
<item name="web/interactive" action="web.swf"/>
</item>
<item name="integrated branding" action="integrated_branding.swf"/>
</item>
</menu>
72dolphins
2/2/2007 3:59:12 PM
AddThis Social Bookmark Button