Problem with variables and path to mc

Hey everybody!

A short description of my project:

  1. Fetching data from mysql
  2. Make x numbers of buttons using duplicateMovieClip. (depends on num_rows from db)
  3. Set text in buttons from db with dynamic text.

I’m talking about the buttons on the left side here:
http://www.distorted-personality.com/index2.html

Here’s the code-snippet i experience problems with.

    for(var a=0;a<10;a++){
         _root.btn_archive.duplicateMovieClip("button"+a,_root.getNextHighestDepth());
     
         button0.archive_txt = lv.tittel0;
       
         button0.onRollOver = function(){
             this.gotoAndStop(2);
         }

… And so on.

If you look a the code above, button0 <- I want that to be something like: button[a].
If I do a trace on trace(“button”+a), it works perfectly.(returns button0, button1 … etc)
If I make it a variable, var tmp:String = “button”+a;, it will also give me the same result.

But if I try to target a mc with path, example tmp.onRollOver = function(){, it will not work.

  • button[a].onRollOver doesnt work.
  • “button”+a.onRollOver doesn’t work.

How can I integrate that a-variable into my path to the newly created mc’s?

Guess any of you in here can help me out! I hope so! :cyclops:

Thanks in advance.