# Problem with variables and path to mc

**URL:** <https://forum.kirupa.com/t/problem-with-variables-and-path-to-mc/208228>\
**Category:** flash\
**Created:** [November 26, 2006, 5:30pm UTC](https://forum.kirupa.com/t/problem-with-variables-and-path-to-mc/208228 "2006-11-26T17:30:23Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![chroma](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@chroma](https://forum.kirupa.com/u/chroma)\
**Post date:** [November 26, 2006, 5:30pm UTC](https://forum.kirupa.com/t/problem-with-variables-and-path-to-mc/208228/1 "2006-11-26T17:30:23Z")

</div>

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](http://www.distorted-personality.com/index2.html)

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

```auto
    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.
