Dynamic Functions for a menu in Flash

Hi all...

I have a Flash movie that reads in a varying number of items from an array.  I want it to dynamically create the onRelease functions for the item.

For Example:

Menu 1 has 3 items, so Flash creates MENU 1, with 1 2 3 underneath.  when you click on 1, you bring up item1, click on 2, bring up item2, etc.
Menu 2 has 5 items, flash does as above, but with 5 clickable links going to item1-5

Now, i have it hardcoded as "btn1.onRelease = function() { blah }" "btn2.onRelease..." etc. but i wanted to know if there's a dynamic way to do it.

Any help will be appreciated. An answer to the above or a better way to do it will be accepted. Thanks!
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

The following code i took from an XML menu I created (did it based on an XML-menu tutorial):

        subs = menu.firstChild.childNodes.childNodes;
        amount = subs.length;
        for (b=0; b<=amount; b++) {
            _root.attachMovie("submenuItem", "subitem"+b, b+20);
            _root["subitem"+b].nametxt = subs[b].attributes.id;
            _root["subitem"+b].itemUrl = subs[b].attributes.theURL;
            _root["subitem"+b].itemTarget = subs[b].attributes.Target;

            // put them in the right possition
            _root["subitem"+b]._y = topypos+(_root["subitem"+b]._height*b)+(_root["item"+nummer]._height);
            _root["subitem"+b]._x = startxpos;

In the above there is a button-movie ready for duplication. So the button holds the "onClick" action allready.

In your situation it would be something like this:
for (b=0; b<subbuttonamount; b++) {
             this["btn" + b].onRelease = function() { getURL("abc.htm") };

Hope the examples get you further!?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
recommend points for dutchfoxer  :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.