Skip to main content
March 16, 2008
Answered

referring a mc inside a mc

  • March 16, 2008
  • 1 reply
  • 483 views
i have a parentmc and a childmc.
parentmc.onRelease=function(){
trace("parentmc was clicked");
}
parentmc.childmc.onRelease=function(){
trace("the child was clicked");
}
what can i do to make it work?
This topic has been closed for replies.
Correct answer
The attached script I did just to illustrate a different point on another forum but I just modified it to be able to drag the "aquarium". Click on any of the three colored buttons under the white window as many times as you want to add fish to the window. Once swimming in the window, each "fish" can be deleted by pressing on it (i.e. each on has an onPress handler. But you can also drag the white window. It does coincidentally enough have a mask.
One issue with the hitTest/drag is that you may not want the MC to drag while you are actually interacting with the buttons contained within it. If that is the case, you can null out the hitTest while over the child buttons and then reapply it when you are off them. I took that previous script and made it so that the MC cannot be dragged if the mouse is over a child button. The changes are in lines 89 - 105

1 reply

Inspiring
March 16, 2008
elic05,

> what can i do to make it work?

I'm not sure I understand your question, exactly. What you've shown
will work for both the parent and the child, one or the other. Are you
trying to get both to respond?


David Stiller
Co-author, Foundation Flash CS3 for Designers
http://tinyurl.com/2k29mj
"Luck is the residue of good design."


March 16, 2008
Yes, I'm trying to get both of them to respond.
Is it possible?
March 17, 2008
You cannot do that directly. You can accomplish that by using a combination of an onRelease handler for one clip and hitTest coupled with a mouse event for the other.