[FMX] Movieclips with linkage

I have 8 mc’s (thumb_01, thumb_02 …thumb_08). Those mc’s are insite another mc (thumbsMC) I control them the following way:

function setButton() {
for (var i in thumbsMc) {
if (thumbsMc*._name.substr(0, 6) == "thumb_") {
clip = thumbsMc*;
clip.onRollOver = function() {
	this.gotoAndStop(2);
};
clip.onRollOut = function() {
	if (!this.pushed) {
	 this.gotoAndStop(1);
	} else {
	 this.gotoAndStop(2);
	}
};
clip.onRelease = function() {
	_root.resetKnop();
	this.pushed = true;
	this.gotoAndStop(2);
};
}
}
}
function resetKnop() {
for (var i in thumbsMC) {
if (thumbsMC*._name.substr(0, 6) == "thumb_") {
clip = thumbsMc*;
clip.pushed = false;
clip.gotoAndStop(1);
}
}
}
setButton();

In the library I have 8 picture mc’s (album01, album02 … album08) all with a linkage. What kind of function do I need to accomplish that when thumb_01 is pressed, album01 is attached to the container on the stage and the same with the other thumbs.

_root.container.attachMovie(“linkageName”",“newname”,level);

will give you:

_root.container.newname

containing the thing that was in the library

Try this on the main timeline
for (var i = 1; i<9; i++) {
thumbsMC[“thumb_0”+i].ivar = i;
thumbsMC[“thumb_0”+i].onPress = function() {
_root.container.attachMovie(“album_0”+this.ivar, “album_0”+this.ivar, this.ivar);
};
}
I`ve done it so each is attached at a different depth but if you want to replace one with another just use the same depth.

Thanks a lot RvGaTe and stringy :wink:

@ stringy

Where do I itegrate this in the excisting script

Thanks in advance

for (var i = 1; i<9; i++) {
thumbsMC[“thumb_0”+i].ivar = i;
}
function setButton() {
for (var i in thumbsMc) {
if (thumbsMc*.name.substr(0, 6) == "thumb") {
clip = thumbsMc*;
clip.onRollOver = function() {
this.gotoAndStop(2);
};
clip.onRollOut = function() {
if (!this.pushed) {
this.gotoAndStop(1);
} else {
this.gotoAndStop(2);
}
};
clip.onRelease = function() {
_root.container.attachMovie(“album_0”+this.ivar, “album_0”+this.ivar, this.ivar);
_root.resetKnop();
this.pushed = true;
this.gotoAndStop(2);
};
}
}
}
setButton();

it does not really go with your script and there is probably a better way but i think it will work

EDIT:-try
if (thumbsMc*.name.substr(0, 6) == "thumb") {
clip = thumbsMc*;
this line-> clip.ivar = Number(clip._name.substr(7, 1));

instead of my loop

The first part isn’t working

I get a little confused. Where should I place that last line ?

clip.ivar = Number(clip._name.substr(7, 1));

And what part should I leave out.

Well the other option is unlikely to work,does the same thing but i thought it matched your code a little better.

for (var i in thumbsMc) {
if (thumbsMc*.name.substr(0, 6) == "thumb") {
clip = thumbsMc*;
clip.ivar = Number(clip._name.substr(7, 1));
clip.onRollOver = function() {
this.gotoAndStop(2);
};

and later

clip.onRelease = function() {
_root.container.attachMovie(“album_0”+this.ivar, “album_0”+this.ivar, this.ivar);
_root.resetKnop();
this.pushed = true;
this.gotoAndStop(2);
};

I did what you;ve said but I cant get it to work. I have attached the zip file. Maybe If you have the time you can have a look at it. To make the file not to heavy I removed the big pictures.

Thanks in advance,
Donald

Anybody else?

I am unable to find anything with linkage identifier album01 etc.
when i wrote the code before i thought you were attaching album_01etc
so if you give linkage identifiers album01,album02…
use
_root.fotos.containerMC.attachMovie(“album0”+this.ivar, “album0”+this.ivar, 5);

try putting a trace in the clip.onRelease and you`ll see what is happening better
trace(this.ivar)
Both sets of code should work with this.

Hi stringy,

It’s almost working :slight_smile: but what should I do to make them load at the same depth?

Just put a value into the depth thing like above
_root.fotos.containerMC.attachMovie(“album0”+this.ivar, “album0”+this.ivar, 5);

One should then replace the other.

That simple :blush: Thank you very very much :thumb: Everything is working fine!

One quoestion of intrest You lately added this line of code:

clip.ivar = Number(clip._name.substr(7, 1));

What is that one doing?

Cheers stringy :beer:

That was instead of the loop
for (var i = 1; i<9; i++) {
thumbsMC[“thumb_0”+i].ivar = i;
}
so you only need one or the other
I just thought it was more in line with how you are scripting.

I understand :slight_smile: Thanks a lot

you are welcome