# How to apply actions to this?

**URL:** https://forum.kirupa.com/t/how-to-apply-actions-to-this/195611
**Category:** flash
**Created:** [August 1, 2006, 10:06pm UTC](https://forum.kirupa.com/t/how-to-apply-actions-to-this/195611 "2006-08-01T22:06:17Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![bennymartensson](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bennymartensson/32/1317_2.png) [@bennymartensson](https://forum.kirupa.com/u/bennymartensson)
#### Post date: [August 1, 2006, 10:06pm UTC](https://forum.kirupa.com/t/how-to-apply-actions-to-this/195611/1 "2006-08-01T22:06:17Z")

</div>

This is the code and my question is, where and HOW do i write my actions? My submenu sections is some external swf’s called sub1.swf, sub2.swf, sub3.swf etc.

Cascading Menu v1.0  
Simon Coulton ([s\_coulton@hotmail.com](mailto:s_coulton@hotmail.com)) - 8/5/2006

// Functions ------------------------------------------------------------------------  
\_global.$tweenManager.broadcastEvents = true;  
// Main menu  
function createMainMenu() {  
var a = 1;  
var total = mm\_array.length;  
while (a\<=total) {  
ypos = ((a-1)\*homm)+1;  
attachMovie(“mainnav\_mc”, “mainnav”+a+"\_mc", this.getNextHighestDepth()+100, {\_x:0, \_y:ypos}); // attach the movieClip  
var nc = this[“mainnav”+a+"\_mc"];  
nc.menutext = mm\_array[(a-1)]; // set the title text for each button  
nc.itemnum = a; // set the menu #  
a++;  
}  
}  
function moveMenu(num) {  
if ((\_root.collapsed == true) || (\_root.selectedmenu != num)) {  
var array = “sm”+num+"\_array";  
var totalsm = eval(array).length;  
var totalmm = mm\_array.length;  
var a = 1;  
while (a\<=totalmm) {  
mc = this[“mainnav”+a+"\_mc"];  
if (a\>num) {  
var ypos = (((a-1)_homm)+1)+totalsm_(hosm+1);  
mc.tween("\_y", ypos, 0.5, “easeOutBack”);  
} else {  
var ypos = ((a-1)\*homm)+1;  
if (a == num) {  
nypos = ypos;  
mc.tween("\_y", ypos, 0.5, “easeOutBack”, 0, onEnd(num, nypos));  
} else {  
mc.tween("\_y", ypos, 0.5, “easeOutBack”);  
}  
}  
a++;  
}  
\_root.collapsed = false;  
} else {  
contractMenu()  
\_root.collapsed = true;  
}  
}  
function onEnd(num, nypos) {  
\_root.num = num;  
createSubMenu(num, nypos);  
}  
function contractMenu() {  
var c = 1;  
while (c\<=submenu\_array.length) {  
removeMovieClip(“subnav”+c+"\_mc");  
removeMovieClip(“mask”+c+"\_mc");  
c++;  
}  
var g = 1;  
while (g\<=mm\_array.length) {  
ypos = ((g-1)\*homm)+1;  
this[“mainnav”+g+"\_mc"].tween("\_y", ypos, 0.5, “easeOutBack”);  
g++;  
}  
}  
function createSubMenu(num, nypos) {  
var array = “sm”+num+"\_array";  
var totalsm = eval(array).length;  
var ypos = nypos+4;  
var c = 1;  
while (c\<=submenu\_array.length) {  
removeMovieClip(“subnav”+c+"\_mc");  
removeMovieClip(“mask”+c+"\_mc");  
c++;  
}  
submenu\_array = [];  
var a = 1;  
while (a\<=totalsm) {  
ypos = ypos+hosm+1;  
attachMovie(“subnav\_mc”, “subnav”+a+"\_mc", a+30, {\_x:0, \_y:ypos});  
if (num != mm\_array.length) {  
attachMovie(“mask\_mc”, “mask”+a+"\_mc", a+990, {\_x:0, \_y:0});  
mask\_mc = this[“mask”+a+"\_mc"];  
mask\_mc.\_alpha = 10;  
mask\_mc.onEnterFrame = function() {  
this.\_height = \_parent.container\_mc[“mainnav”+mm\_array.length+"\_mc"].\_y;  
};  
this[“subnav”+a+"\_mc"].setMask(mask\_mc);  
}  
nc = this[“subnav”+a+"\_mc"];  
nc.\_alpha = 0;  
nc.itemnum = a;  
nc.menutext = eval(array)[(a-1)];  
nc.alphaTo(100, 2);  
nc.onRelease = function() {  
// Function to get submenu actions needs to go here  
var my\_str:String = new String(this);  
\_root.select = “You have selected “+my\_str.slice(18);  
};  
submenu\_array.push(“subnav”+a+”\_mc”);  
a++;  
}  
}  
// Build Menu -----------------------------------------------------------------------  
\_root.collapsed = true;  
createMainMenu();
