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:

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

    for(var a=0;a<10;a++){
         button0.archive_txt = lv.tittel0;
         button0.onRollOver = function(){

… 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.