In Flash MX.
Hi everyone,
I am almost finished with my UrbanPlan project, which allows users to drag different building structures onto a map and print the design, but I am experiencing a major problem with the Clear All button that is to remove all duplicated MCs. This is the last step I need for my project. Please help! I have attached the fla file below.
In my fla file, I have a MC called ¡°component library¡± which contains 2 other MCs, namely ¡°office¡± and ¡°residential¡±. For example, in ¡°office¡± MC, there are two types of office buildings, lowrise and midrise. I made graphic symbols for lowrise and midrise, and set the Linkage Property on them. For example, I gave the symbol ¡°lowrise¡± a linkage identifier: lowrise1a¡±. Then I dragged the ¡°lowrise¡± symbols onto the ¡°office¡± MC, and convert it to a MovieClips with an instance name ¡°original-lowrise1a¡±. Then I went into the ¡°original-lowrise1a¡± MC, and defined the following frame action:
this.xHome = this._x;
this.yHome = this._y;
this.onPress = startDrag;
this.onRelease = this.onReleaseOutside=function () {
stopDrag();
if (this._name == “original-lowrise1a”)
{
_root.d++;
var myDupe = _parent.attachMovie(“lowrise1a”, “lowrise1a”+_root.d, _root.d);
myDupe._x = this._x;
myDupe._y = this._y;
this._x = this.xHome;
this._y = this.yHome;
}
};
So far, this is all working just fine. The pieces are duplicated and draggable. However, I also want a ¡°Clear All¡± button that removes all building structures from the map, and here is where I have a major problem. On the button, I tried the following action:
on (release) {
for (var i = 1; i<=_root.d; i++) {
_root[“lowrise1a”+i].removeMovieClip();
_root[“midrise”+i].removeMovieClip();
}
}
It¡¯s not doing anything. I suspect it¡¯s probably because the ¡°original-lowrise1a¡± MC is several levels down from the main scene, and the ¡°Clear All¡± button need to address the correct MC in order to delete duplicated MCs. I have no idea how to achieve this. Namely, I want to go through each MC (original-lowrise1a, original-midrise, etc) and remove all subsequent MCs generated by them. Can someone please help? Thank you!!