# How do i set dynamic background names?

**URL:** <https://forum.kirupa.com/t/how-do-i-set-dynamic-background-names/266672>\
**Category:** Uncategorized\
**Created:** [July 23, 2008, 10:09am UTC](https://forum.kirupa.com/t/how-do-i-set-dynamic-background-names/266672 "2008-07-23T10:09:39Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![keitai](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@keitai](https://forum.kirupa.com/u/keitai)\
**Post date:** [July 23, 2008, 10:09am UTC](https://forum.kirupa.com/t/how-do-i-set-dynamic-background-names/266672/1 "2008-07-23T10:09:39Z")

</div>

Hi all,

I am stuck with developing a xml based menu (based on kirupa’s tutorial).

All the nav links are correct but i am having problems with the background color and placing the submenu nav links.

For the background color i am have created a function drawBG. At the moment i have set the name static, but i realise that sometimes i have 3 submenu.  
So i can’t use the same name over and over again. How do i create the names dynamicly for say 3 submenu’s  
so i have something, like

mainMenuBG - submainMenuBG - subsubmainMenuBG - subsubsubmainMenuBG

```auto

function generateMenuNew(container, name, xPos, yPos, depth, node_xml, bgMenuDepth, bgName) {
	var curr_node:XML;
	var curr_item:MovieClip;
	//important first the background then menu
	drawBG(websiteContent.getNextHighestDepth(), "mainMenuBG", 0xE3E3E3, 160, 430, 0, 0, 1);

curr_item.onRelease = function() {
			generateSubMenu(curr_menu, "submenu_mc", curr_item._x+websiteContent.mainMenuBG._width, 225, 1000, this.node_xml, 1, 0xFCCBAC);

		};
......
}

function generateSubMenu(container, name, x, y, depth, node_xml, animateBG, clrBG) {
	var animateBG:Boolean;
	var clrBG;
	var curr_node:XML;
	var curr_item:MovieClip;
	var curr_menu = container.createEmptyMovieClip(name, depth);
	//boolean animate background
	drawBG(1, "submainMenuBG", clrBG, 145, 205, 165, 225, animateBG);

........

}

function drawBG(menuDepth, bgName, bgColor, bgWidth, bgHeight, bgX, bgY, animateBG) {
	var animateBG:Boolean;
	var menuBG:MovieClip = websiteContent.createEmptyMovieClip(bgName, menuDepth-2);
	menuBG.beginFill(bgColor, 100);
	menuBG.lineTo(0, bgHeight);
	menuBG.lineTo(bgWidth, bgHeight);
	menuBG.lineTo(bgWidth, 0);
	menuBG.lineTo(0, 0);
	menuBG.endFill();
	menuBG._x = bgX;
	menuBG._y = bgY;
	createMask(bgName,bgWidth, bgHeight, bgX, bgY);
	menuBG.setMask(thisMask);
	if(animateBG == 1){
		var showBGTween = TweenLite.from(websiteContent[bgName], 0.7, {_x: -100,_alpha:0, ease:Ease.easeOutBack});
	}
}

```

---

<div class="post-metadata">

**Author:** ![keitai](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@keitai](https://forum.kirupa.com/u/keitai)\
**Post date:** [July 27, 2008, 4:46pm UTC](https://forum.kirupa.com/t/how-do-i-set-dynamic-background-names/266672/2 "2008-07-27T16:46:10Z")

</div>

ttt with the latest .fla

(unfort. still no good)

---

<div class="post-metadata">

**Author:** ![keitai](https://avatars.discourse-cdn.com/v4/letter/k/73ab20/32.png) [@keitai](https://forum.kirupa.com/u/keitai)\
**Post date:** [July 27, 2008, 8:23pm UTC](https://forum.kirupa.com/t/how-do-i-set-dynamic-background-names/266672/3 "2008-07-27T20:23:26Z")

</div>

taken another babystep, but not there yet. please take a look

- my first submenu bg disappears
- the subsubmenu bg don’t dissappear

regards
