PDA

View Full Version : Problem with attachMovie loop.


andrew444
08-10-2008, 05:40 AM
Hey all! I hope everyone is well out there.

I have a problem that I am going to try and explain. Any help would be suhweet!

On my stage, I have four MCs. One is a box (inv), and nested inside "inv" is another box ("inv1"). There is also a red circle ("red_circle") and a man ("man").

"red_circle" is a MC with a nested button coded as follows:

on (press) {
startDrag(this);
}
on (release) {
stopDrag();
if (eval(this._droptarget) == _root.inv.inv1) {
trace("You have placed a Red Circle in the box!");
this.unloadMovie(this);
_root.inv.inv1.attachMovie("red_circle", "red_circle", 1);
}
if (eval(red_circle._droptarget) == _root.man) {
trace("The man has placed a Red Circle in the box!");
this.unloadMovie(this);
_root.inv.inv1.attachMovie("red_circle", "red_circle", 1);
}
}

When I drop "red_circle" on _root.inv.inv1 or on _root.man, I want "red_circle" to unload itself and _root.inv.inv1 to reattach the "red_circle" movie.

This all works like a charm, except that when I drag and drop the newly attached "red_circle" on its _droptarget(s), it unloads and traces the messages, but does not reattach a new one.

Does this make sense? And if so, what am I doing wrong? Do I need to do some funky loop to make this work?

Click here for the FLA if you need to see what I'm up to. (http://www.geocities.com/synchronicitree/redball.fla)

Thanks for your help! :)

Andrew444

PS: I have the linkage properties set right....I think!

andrew444
08-12-2008, 05:00 AM
I figured this out!

It seems (and I think this is just a Flash idiosynchrocy) that I need to unload the MC AFTER I call attachMovie.

The problem code:

on (release) {
stopDrag();
if (eval(this._droptarget) == _root.inv.inv1) {
trace("You have placed a Red Circle in the box!");
this.unloadMovie(this);
_root.inv.inv1.attachMovie("red_circle", "red_circle", 1);}
}

The right code:

on (release) {
stopDrag();
if (eval(this._droptarget) == _root.inv.inv1) {
trace("You have placed a Red Circle in the box!");
_root.inv.inv1.attachMovie("red_circle", "red_circle", 1);}
this.unloadMovie(this);}
}

Humm. Weird...

PS: It was my girlfriend who has ZERO experience with Flash who helped me see the light with this one. I bow before her smartness. :)

Andrew444