# Linking for AS + external as files problem

**URL:** https://forum.kirupa.com/t/linking-for-as-external-as-files-problem/206465
**Category:** Uncategorized
**Created:** [November 8, 2006, 1:01pm UTC](https://forum.kirupa.com/t/linking-for-as-external-as-files-problem/206465 "2006-11-08T13:01:22Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![thatguythatsme](https://avatars.discourse-cdn.com/v4/letter/t/c0e974/32.png) [@thatguythatsme](https://forum.kirupa.com/u/thatguythatsme)
#### Post date: [November 8, 2006, 1:01pm UTC](https://forum.kirupa.com/t/linking-for-as-external-as-files-problem/206465/1 "2006-11-08T13:01:22Z")

</div>

I’m using a script to load external jpegs from a folder names images and I want to be able to navigate these images with buttons…

I’ve got everything wrking fine but I’m now trying to update the script into an external actionscript file.  
My problem is before I used the button script on the button movie clip but now its external I cant seem to define the buttons instance unless I specifically call it MC\_Button5 for the fifth button…

I’ve tried a few different ways with no sucess…

```auto
varspreads = 10;
varImageLocation = "images";
varSelected = 1;
for (i=0; i<_root.varspreads; i++) {
    _root.attachMovie("MC_Button", "MC_Button"+i, i*10);
    _root["MC_Button"+i]._x = 3+(i*16);
    _root["MC_Button"+i]._y = 400;
    if (i+1 == varSelected) {
        _root["MC_Button"+i].gotoAndStop("selected");
        _root.placeHolder.loadMovie(varImageLocation+"/"+(i+1)+".jpg");
    }
}
function clearSelected() {
    for (i=0; i<_root.varspreads; i++) {
        _root["MC_Button"+i].gotoAndStop("normal");
    }
}
MC_Button.onPress = function() {
    trace("button pressed");
    _root.placeHolder.loadMovie(_root.varImageLocation+"/"+(int(_name.substring(9, 10))+1)+".jpg");
    _root.clearSelected();
    _root["MC_Button"+(int(_name.substring(9, 10)))].gotoAndPlay("selected");
};

```

Does anyone have any suggestions?

Dave
