for (var i = 2; i<=maxvalue; i++)
{duplicateMovieClip(“clip”, “clip”+i, i);
…
…
and so on
so you see I want to duplicate a movieclip here as much as ‘maxvalue’ times. It works fine. But inside the duplicated movieclips is another movieclip/button and its (unique) behaviour is controlled by the following script: (I also placed this in the “for”-loop (?))
…
clipnumber = eval(“clip”+i);
clipnumber.submovie.onRelease = function() {
getURL(“detailpage”+i,“target”);
};
…
but this i variable is not reachable from within the function. I suppose I am making very fundamental mistakes, but can somebody help me out and show me the right way to do this?
I had the same problem a couple of days ago
You have to define the i variable for each movie (especially because it’s in a loop)
for (var i = 2; i<=maxvalue; i++)
{
mc=duplicateMovieClip("clip", "clip"+i, i);
// you don't need clipnumber, you manipulate mc
mc.i=i;
mc.submovie.onRelease = function()
{
getURL("detailpage"+_parent.i,"target");
}
};
for (var i = 2; i<=maxvalue; i++)
{
mc=duplicateMovieClip("clip", "clip"+i, i);
// in fact, mc=this["clip"+i]
mc.i=i;
// we define the i variable of this particular movie clip
mc.submovie.onRelease = function()
// submovie should be a clip that already exist in clip
{
// I put _parent because you have to go one level up in
// the hierarchy. If this doesn't work, you could try to put
// mc.i instead
getURL("detailpage"+_parent.i,"target");
}
};