Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 07-15-2002, 07:58 PM   #1
cramroop
Registered User
 
Join Date: Jun 2002
Posts: 2
Default nested movieclips and events

I have three clips, Clip1, Clip2, Clip3.

Clip1 contains Clip2 which contains Clip3 (nested).


I attached and onRollOver event handler on Clip2 which fires and does what it's suppose to. However, when I attach an onRollOver event handler to Clip1 it, althought it fires, the Event on Clip2 does not.

Is there any way to get these nested events to fire?
cramroop is offline   Reply With Quote
Old 07-16-2002, 05:47 AM   #2
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

If Clip1 is a button with a rollOver event, rollingOver Clip2 will only trigger the Clip1 event because Clip2 is part of the active hit area of Clip1 by default. The easiest way to overcome this is probably to make your 3 clips "siblings" of the same parent rather than nesting them within each other.

There's also a way to specify a particular clip as the "hitArea" of a MovieClip/Button.
ActionScript Code:
Clip1.hitArea = SomeClip;
Just be sure when you specify the hitArea for Clip1 it doesn't contain Clip2 and when you specify the hitArea for Clip2 it doesn't contain Clip3.

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 09-08-2002, 12:40 AM   #3
VoxHedra
Registered User
 
Join Date: Aug 2002
Posts: 3
Smile Further Question....

Hi Pixelwit,

On the topic of hitArea, I have another question for you:

I have a movie clip (nav) of a rollout menu with an event handler on frame one. Nested within is another movie clip (background tab) which has a tweened mask that rolls in and out. Also beneath this mask are buttons.

So...
Mask
-button text
-background tab (mc)

Is it possible to make the hitArea of "Nav" be the background tab mc while still preserving the hit states of the buttons? Technically the tab mc is beneath the buttons so there should be no hit area conflict but this approach *doesn't work. Background Tab must be nested inside nav b/c its being masked. Is it best to use invisible buttons in this case?

This is my code....

Code:
nav.hitArea = nav.backgroundtab;
nav.onRollOver = function() {
     nav.gotoAndPlay ("open");
}
VoxHedra is offline   Reply With Quote
Old 09-08-2002, 01:23 AM   #4
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

I'm not sure I fully understand your question/problem. If you attach a sample file, I'll take a look and see what I can come up with.

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 09-08-2002, 03:03 AM   #5
VoxHedra
Registered User
 
Join Date: Aug 2002
Posts: 3
Default Sample File

Here is a sample file. Its a bit different than my previous scenario but the aim is the same. In the main movie when you click on "stuff," it should load the external movie into the blank mc. But the button doesn't work...I'm trying to accomplish this with event handlers rather than invisible hit states. Hopefully you can help

vox
Attached Files
File Type: zip testfiles.zip (9.4 KB, 159 views)
VoxHedra is offline   Reply With Quote
Old 09-09-2002, 05:40 AM   #6
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

I've done a little experimenting and I don't think it's gonna happen.

Observation: Although your mouse may be over a space occupied by two overlapping buttons Flash will only register an "Over" condition with one of the two buttons.

Deduction: If you are over ButtonA, you can't be over a ButtonB. If you "WERE" over ButtonA but "ARE" over ButtonB, you are "OUT" of ButtonA. This means RollingOver ButtonA triggers a RollOut event in ButtonB.

What I think this means to you: You can't use a RollOut event to close your Menu since RollingOver any button within the Menu will trigger an unwanted RollOut event.

Solution: The old "standby", create an "invisible hit state" which occupies all the space your Menu doesn't then use it to trigger a RollOver event to close the Menu.

Hope it helps,

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Old 09-09-2002, 05:51 AM   #7
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default Can anyone tell me why...

If I change the code in VoxHedra's file to this:
ActionScript Code:
Menu.Orange.onRollOver = function() {     Menu.gotoAndPlay ("open"); } Menu.Orange.onRollOut = function() {     Menu.gotoAndPlay ("close"); } stop();
Why does Menu.Orange stop functioning as a button as soon as Menu plays? I'm assuming it has something to do with the fact that Menu contains a mask which masks Menu.Orange yet Menu.Orange is masked from the beginning so I don't see any reason it's state should change.

Just curious,

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.

Last edited by pixelwit; 09-09-2002 at 05:56 AM.
pixelwit is offline   Reply With Quote
Old 09-09-2002, 06:12 PM   #8
VoxHedra
Registered User
 
Join Date: Aug 2002
Posts: 3
Default Confusing...

Quote:
Originally posted by pixelwit
Deduction: If you are over ButtonA, you can't be over a ButtonB. If you "WERE" over ButtonA but "ARE" over ButtonB, you are "OUT" of ButtonA. This means RollingOver ButtonA triggers a RollOut event in ButtonB.
http://www.pixelwit.com
This has always drove me insane.

So imagining that ButtonB is on top of Button A, if you are on ButtonA you can't be over ButtonB because:

Quote:
Although your mouse may be over a space occupied by two overlapping buttons Flash will only register an "Over" condition with one of the two buttons.
This is true.

What I've never understood is: If you roll OVER ButtonB, doesn't that activate the RollOut event of ButtonA and the RollOver event of ButtonB simultaneously (which causes a bug)? Similarly, If you roll OFF ButtonB, doesn't that activate the rollOver event of ButtonA and the rollOut event of ButtonB? Which event takes precedence in both cases?

Quote:
You can't use a RollOut event to close your Menu since RollingOver any button within the Menu will trigger an unwanted RollOut event.
I normally solve this problem by having the rollOver of any button, go to the "freeze" frame of the menu animation. Also another way I do it, is to use "true/false" variables to register the open and close states of an animation...that way you can have a button on top of a larger button.

I guess invisible hit states are still the way to go...Event Handler Methods & hit states can get tricky and should probably be used for simpler things then nested movie clips

vox
thx for the help so far pixelwit.
VoxHedra is offline   Reply With Quote
Old 09-09-2002, 06:45 PM   #9
pixelwit
village halfwit
 
pixelwit's Avatar
 
Join Date: Jul 2001
Location: USA, PA
Posts: 3,330
Default

Quote:
What I've never understood is: If you roll OVER ButtonB, doesn't that activate the RollOut event of ButtonA and the RollOver event of ButtonB simultaneously (which causes a bug)? Similarly, If you roll OFF ButtonB, doesn't that activate the rollOver event of ButtonA and the rollOut event of ButtonB? Which event takes precedence in both cases?
I doubt anything in ActionScript happens simultaneously. I'm guessing the order of execution is determined by the stacking order of the buttons on the stage. Don't know for sure, I never checked.

You could make a test FLA file and put some trace actions on different buttons, move them around and stuff then see which events happen when.

Glad to have helped,

-PiXELWiT
http://www.pixelwit.com
__________________
There are no answers, only choices.
pixelwit is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Event Listeners not working w/ Nested MovieClips ? pcarini ActionScript 2.0 3 02-06-2005 10:49 PM
Mouse events don't work on attached movie fuqur2dom ActionScript 2.0 3 10-05-2004 07:56 AM
how to turn mouse events off for overlapping object and keep visible yorkeylady ActionScript 2.0 2 04-28-2004 07:57 AM
MC : Redefine events for nested movieclips JabbyPanda ActionScript 1.0 (and below) 3 02-07-2003 11:18 PM
adding onLoad events to createEmptyMovieclips pixelwhore ActionScript 1.0 (and below) 5 10-25-2002 12:43 AM


All times are GMT. The time now is 10:18 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.