-
1. Re: Remove attached movieclip in reverse order of placement
ckpepper02 Aug 21, 2009 8:02 AM (in response to ScottLuker)Perhaps using an array to store the movie clips names that are attached would work. Then you could use the array.pop() method to get the last element entered and remove it from the array at the same time.
I bolded the lines I changed/added in your code.
var i:Number = 0;
var dotArrays = new Array();
this.onMouseDown = function(){
var drawdot:MovieClip;drawdot = this.attachMovie("dot", "dot_mc" + i, this.getNextHighestDepth(), {_x:_xmouse, _y:_ymouse});
dotArrays.push(this["dot_mc" + i]._name);
var nextdepth = this.getNextHighestDepth();
trace (nextdepth);
}clear_btn.onPress = function() {
var delete_mc = dotArrays.pop();
removeMovieClip(delete_mc);
}
}Let me know if this works ok.
-
2. Re: Remove attached movieclip in reverse order of placement
ScottLuker Aug 21, 2009 8:17 AM (in response to ckpepper02)Thanks for your response ckpepper. Your suggestion produces the same result, in that the dots are deleted in the order there were attached (ie. 1,2,3, instead of 3,2,1). I traced the value delete_mc on clear_btn.onPress and got the results:
dot_mc0
dot_mc0
dot_mc0Scott
-
3. Re: Remove attached movieclip in reverse order of placement
ckpepper02 Aug 21, 2009 8:22 AM (in response to ckpepper02)Sorry! I forgot a line.
After: dotArrays.push(this["dot_mc" + i]._name);
Add: i++;
-
4. Re: Remove attached movieclip in reverse order of placement
ScottLuker Aug 21, 2009 8:40 AM (in response to ckpepper02)You are brilliant! Works like a charm. Thanks so much.
-
5. Re: Remove attached movieclip in reverse order of placement
ckpepper02 Aug 21, 2009 8:43 AM (in response to ScottLuker)Yay! Your welcome.