Skip to main content
Inspiring
June 5, 2014
Answered

duplicate 2 attach 1 and mask attached?

  • June 5, 2014
  • 1 reply
  • 421 views

My AS2 code (not working):

var btnX:Array=[gpat_btn0, gpat_btn1, gpat_btn2];

var attX:Array=["pat0","pat1","pat2"];

for(i=0;i<btnX.length;i++){

  btnX.pvar=i;

  btnX.onRelease = function(){

  for(s=0;s<2;s++){

  _root.movieC1.movieC2.C2.duplicateMovieClip(_root.movieC1.movieC2["clip"+s], _root.movieC1.movieC2.getNextHighestDepth());

  }

  _root.movieC1.movieC2.clip0.attachMovie(attX[this.pvar], attX[this.pvar], _root.movieC1.movieC2.C2.getNextHighestDepth());

  _root.movieC1.movieC2.clip1.setMask(_root.movieC1.movieC2.clip0);

  }

}

I want to create 2 duplicates of [ _root.movieC1.movieC2.C2 ] inside the same movieclip [ _root.movieC1.movieC2 ].

Attach a [ attX ] in one of the duplicates created.

Mask the above attached movieclip with the other duplicate.

This topic has been closed for replies.
Correct answer kglad

again, you can't reparent a duplicated movieclip.  your duplicate will have a parent that is the timeline that contains the duplicateMovieClip code.

so, you could use code in _root.movieC1.movieC2;

function duplicateC2():MovieClip{

return this.C2.duplicateMovieClip("c2dup",this.getNextHighestDepth());

}

1 reply

kglad
Community Expert
Community Expert
June 5, 2014

you can create duplicates (using a string for the name) but you can't reparent using as2 with attachMovie or otherwise.

Inspiring
June 5, 2014

Thanks but I don't need to reparent the duplicate movieclips, I want to be able to duplicate the movieclips within the same original movieclip.

Eg:

Original movieclip is C2. resides in _root.movieC1.movieC2

Duplicates to be created are clip0 and clip1 inside _root.movieC1.movieC2

Any suggestions how I can achieve my requirement?

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
June 5, 2014

again, you can't reparent a duplicated movieclip.  your duplicate will have a parent that is the timeline that contains the duplicateMovieClip code.

so, you could use code in _root.movieC1.movieC2;

function duplicateC2():MovieClip{

return this.C2.duplicateMovieClip("c2dup",this.getNextHighestDepth());

}