PDA

View Full Version : Newbie creating collapsible folders


simplylezz
11-21-2002, 05:11 AM
I have been trying to create a collapsible directory structure with a folder movie clip that is supposed to duplicate itself into children when it is clicked on. I have created an instance of the mc and called it 'parent'. In the instance's actions i have placed the following code:

onClipEvent (load) {
i = 1;
}
onClipEvent (mouseUp) {
if (this.hittest(_root._xmouse,_root._ymouse,true)) {
duplicateMovieClip (this, "child"+i, i);
setProperty ("child"+i, _y, this._y+this._yscale);
i += 1;
}
}

However, at runtime, it takes three mouse-up actions for the child to be ceated the first time (child created on the fourth click). On the fifth click, the child disappears, but reappears on click no. 6, and so on.
Also, putting a 'trace("child no."+i)' statement before the i+=1 produces an ever increasing series of haphazard numbers, as follows:
CLICK #1: child no.1
CLICK #2: child no., child no.2
CLICK #3: child no.1, child no.3
CLICK #4: child no.1, child no.1, child no.4 (Child appears here)
CLICK #5: child no.1, child no.1, child no.2' child no.5 (Child disappears now)
...etc...
What am I doing that's so wrong? Um... I'm using Flash 5. The fla file is attached with this post.

farafiro
11-21-2002, 09:19 AM
u just need to call the duplicated MC as this["child"+i], also the hitTest wasn't right spelled
onClipEvent (load) {
i = 0;
}
onClipEvent (mouseDown) {
if (this.hitTest(_root._xmouse, _root._ymouse, true)) {
i ++
duplicateMovieClip(this, "child"+i, i);
setProperty(this["child"+i], _y, this._y+this._yscale);

}
}

simplylezz
11-22-2002, 07:47 AM
Thanks, it works now... but what if I need to address the child mc from within the parent's code? I mean, suppose I wanted to create the child and make it wobble for a few seconds when it loads, and I need to make this action happen from within the parent?

Also, is there a way to script lines in Flash 5?