# Combine Scripts

**URL:** <https://forum.kirupa.com/t/combine-scripts/33507>\
**Category:** flash\
**Created:** [October 20, 2003, 2:27pm UTC](https://forum.kirupa.com/t/combine-scripts/33507 "2003-10-20T14:27:44Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![wyclef](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wyclef](https://forum.kirupa.com/u/wyclef)\
**Post date:** [October 20, 2003, 2:27pm UTC](https://forum.kirupa.com/t/combine-scripts/33507/1 "2003-10-20T14:27:44Z")

</div>

Hi,

How can I combine Script #2 with Script #1? I want to be able to keep the linkArray name different from the folio\_arr names because the folio\_arr names are the same as how the swf files are named and the linkArray names are how they appear in text in flash. Script #2 also contains the onRelease functionality. Thanks

Script #1  
[AS]  
// --------------------------------------------------------------------------------------  
// array of link names used in the dynamic text field name dText  
linkArray = [“01”, “02”, “03”, “04”, “05”, “06”, “07”, “08”, “09”, “10”, “11”, “12”, “13”, “14”, “15”, “16”, “17”, “18”, “19”, “20”, “21”, “22”, “23”, “24”];  
// our starting depth  
depth = 6;  
// our starting coordinates  
startX = 255;  
startY = 133;

// our multiplication number so the clips are stacked on each other  
n=0;  
// our loop that creates a link for each element in linkArray  
for (var i = 0; i\<linkArray.length; i++) {  
// if i equals have the array length  
// we should start a new row  
if(i==Math.ceil(linkArray.length/2)) {  
startX+=130  
n=0;  
}  
// attach the movieClip to \_root’s timeline  
var x = \_root.attachMovie(“dynamicLink”, “dlink”+depth, depth++);  
// put them in their places  
x.\_x = startX;  
x.\_y = startY+(x.\_height_n);  
// assign their text  
x.dText.text = linkArray_;  
// incriment the number  
n++;  
}  
[/AS]

Script #2  
[AS]  
// --------------------------------------------------------------------------------------  
folio\_arr = [“jbf”, “crn”, “mrd”, “ald”, “emi”, “win”, “boo”, “tox”, “exc”, “wwn”, “qua”, “eud”, “sms”, “yat”, “tag”, “ten”];  
// --------------------------------------------------------------------------------------  
for (i = 0; i \< folio\_arr.length; i++) {  
this[“folio” + (i + 1)].i = i;  
this[“folio” + (i + 1)].onRelease = function() {  
loadMovie(“portfolio/” + folio\_arr[this.i] + “.swf”, “folioClip”);  
folioClip.preload(627, 201, 170, 16, 3, 0xD1D1D1, 0x333333);  
};  
}  
// --------------------------------------------------------------------------------------  
unloadMovie(“folioClip”);  
[/AS]

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2003, 2:52pm UTC](https://forum.kirupa.com/t/combine-scripts/33507/2 "2003-10-20T14:52:44Z")

</div>

I’m not sure I understand you but I think that what u want is if you’ve got as many linking buttons as movies to load, load a movie that is in the same index number in the movies list as the number of the clicked link in the links list.

What i allways use is associative arrays (arrays of objects) like :  
[AS]myArray\_array = [{link:“01”, folio:“jbf”}, …,{link:“99”, folio:“ddg”}];  
[/AS]

and to retrieve the data:

[AS]

for(var i=0; i\<myArray\_array.length; i++){  
var butt = myArray\_array\*.link;  
butt.smthing = this;  
var folio = String(“portfolio/”+myArray\_array\*.folio+".swf");  
butt.onRelease = function (){  
loadMovie(folio, this.smthing.folioClip);  
}  
}  
[/AS]

SHO

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2003, 3:06pm UTC](https://forum.kirupa.com/t/combine-scripts/33507/3 "2003-10-20T15:06:49Z")

</div>

I understand the associative arrays part but am still confused about how to merge everything.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2003, 3:26pm UTC](https://forum.kirupa.com/t/combine-scripts/33507/4 "2003-10-20T15:26:31Z")

</div>

[AS]  
myArray\_array = [{link:“01”, folio:“jbf”}, …,{link:“99”, folio:“ddg”}];  
depth = 6;  
startX = 255;  
startY = 133;  
n=0;  
for(var i=0; i\<myArray\_array.length; i++){  
var textContent= myArray\_array\*.link;  
var butt = myArray\_array\*.folio;  
butt.smthing = this;  
var folioMovie = String(“portfolio/”+myArray\_array\*.folio+".swf");  
if(i==Math.ceil(myArray\_array.length/2)) {  
startX+=130  
n=0;  
}  
var x = \_root.attachMovie(“dynamicLink”, “dlink”+depth, depth++);  
x.\_x = startX;  
x.\_y = startY+(x.\_height\*n);  
x.dText.text = textContent;  
n++;  
butt.onRelease = function (){  
loadMovie(folioMovie, this.smthing.folioClip);  
}  
}  
[/AS]

Is this what u mean?

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [October 20, 2003, 9:07pm UTC](https://forum.kirupa.com/t/combine-scripts/33507/5 "2003-10-20T21:07:02Z")

</div>

Hi, I got what I was trying to do to work, however i’m not sure how optimized/efficient it is. Can you take a look, also, I can’t unload the dlink movie. The necessary code is in sectionMC\_03 and the dlink MC.

I think that the whole sectionMC\_03 clip is unloaded when you click elsewhere in the site so if I change [AS]var x = \_root.attachMovie(“dynamicLink”, “dlink”+depth, depth++);[/AS] to “this” instead of “\_root” it sort of solves the problem, because when sectionMC\_03 dissappears so does the attached movie however when you return the movie is not reattached it’s already there so the flow is all screwed up. How can I completely remove/unload and reattach these dlink clips everytime?
