Combine Scripts

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._heightn);
// 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]

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

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

[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?

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?