all groups > flash actionscript > february 2004 >
You're in the flash actionscript group:
parent mc mouse events block child's
flash actionscript:
I have been working on a movie clip that will display different text every 30 seconds. When the user moves his mouse over the clip, I wanted the text to be shifted up 40 pixels or so (i have limited real-estate to work with) and have a few buttons display in the open space which the use can press to move the text to the first, last, previous, or next text. When the user moves his mouse out of the text/button area, I wanted the text field to shift back down and the buttons to disappear. To accomplish this I created a movie clip (call it p1_mc). This clip contains two movie clips: a movie clip controlling the text (c1_mc) and a movie clip to hold the buttons (c2_mc). I defined p1_mc.onRollOver and p1_mc.onRollOut to handle shifting the text field (c1_mc) up/down and fading the buttons (c2_mc) in/out. The problem is, on defining onRollOver/onRollOut in p1_mc, the buttons in c2_mc no longer respond to mouse events. After searching through the Action Script forum, I found other users having similar issues...apparently a parent movie clip with mouse events defined will prevent the activation of mouse event handlers in child movie clips. What is a good work-around to this? What is the proper way to code this? The way i initially programmed it seem logical...but it does not work... Any Ideas?
one remedy: on the timeline that contains c1_mc and c2_mc insert a layer below the layer(s) that contain c1_mc and c2_mc and place a movieclip with a size and color that suits your needs. give that background movieclip an instance name, if needed and assign code to your three movieclips.
Thanks for the info! It got me headed in the right direction. I finally have it working at 2:20am local (sheese). I wish there was some mechanism to allow a parent mc to define a rollover event AND allow it's children to be able to react to mouse events as well. Maybe next version? Thanks Again!
You said you figured out what you will to do. Can you explain this? I need to have both the parent and the embeded children movie clips receive Press, Release, and MouseMove events. (I suppose I can have all clips on stage receive MouseUp, Down, Move) and then do filtering via hitTest() but there must be a less performance intensive work. Espcially since my target is the PPC2003!
And what if you are using AS2, and what you want to do is temporarily remove the event and restore, and the event was declared: function onPress():Void { } In the class definition of the parent movie clip Dynamic class parentClass extends MovieClip { .... } [quoted text, click to view] "jr" <john_ryan@jrdesign.com.au> wrote in message news:c1ujln$5u2$1@forums.macromedia.com... > Yep, old problem. > try using : > delete this.onEvent // where event could be 'Rollover' > > or delete this._parent.OnEvent > > John Ryan > Melbourne Australia > > > "EverQuest" <webforumsuser@macromedia.com> wrote in message > news:c1tkj8$3b3$1@forums.macromedia.com... > > I have been working on a movie clip that will display different text every > 30 > > seconds. When the user moves his mouse over the clip, I wanted the text > to be > > shifted up 40 pixels or so (i have limited real-estate to work with) and > have a > > few buttons display in the open space which the use can press to move the > text > > to the first, last, previous, or next text. When the user moves his mouse > out > > of the text/button area, I wanted the text field to shift back down and > the > > buttons to disappear. > > > > To accomplish this I created a movie clip (call it p1_mc). This clip > contains > > two movie clips: a movie clip controlling the text (c1_mc) and a movie > clip to > > hold the buttons (c2_mc). I defined p1_mc.onRollOver and p1_mc.onRollOut > to > > handle shifting the text field (c1_mc) up/down and fading the buttons > (c2_mc) > > in/out. The problem is, on defining onRollOver/onRollOut in p1_mc, the > buttons > > in c2_mc no longer respond to mouse events. > > > > After searching through the Action Script forum, I found other users > having > > similar issues...apparently a parent movie clip with mouse events defined > will > > prevent the activation of mouse event handlers in child movie clips. > > > > What is a good work-around to this? What is the proper way to code this? > The > > way i initially programmed it seem logical...but it does not work... > > > > Any Ideas? > > > >
Yep, old problem. try using : delete this.onEvent // where event could be 'Rollover' or delete this._parent.OnEvent John Ryan Melbourne Australia [quoted text, click to view] "EverQuest" <webforumsuser@macromedia.com> wrote in message news:c1tkj8$3b3$1@forums.macromedia.com... > I have been working on a movie clip that will display different text every 30 > seconds. When the user moves his mouse over the clip, I wanted the text to be > shifted up 40 pixels or so (i have limited real-estate to work with) and have a > few buttons display in the open space which the use can press to move the text > to the first, last, previous, or next text. When the user moves his mouse out > of the text/button area, I wanted the text field to shift back down and the > buttons to disappear. > > To accomplish this I created a movie clip (call it p1_mc). This clip contains > two movie clips: a movie clip controlling the text (c1_mc) and a movie clip to > hold the buttons (c2_mc). I defined p1_mc.onRollOver and p1_mc.onRollOut to > handle shifting the text field (c1_mc) up/down and fading the buttons (c2_mc) > in/out. The problem is, on defining onRollOver/onRollOut in p1_mc, the buttons > in c2_mc no longer respond to mouse events. > > After searching through the Action Script forum, I found other users having > similar issues...apparently a parent movie clip with mouse events defined will > prevent the activation of mouse event handlers in child movie clips. > > What is a good work-around to this? What is the proper way to code this? The > way i initially programmed it seem logical...but it does not work... > > Any Ideas? >
I was able to solve my problems pretty simply with an invisble button. I think this might contain your solution for the rollOff problem: http://flashmx2004.com/forums/index.php?showtopic=995 O'Reilly has a hack that also deals with this, but they don't cover the roll off http://www.oreillynet.com/pub/h/1060 [quoted text, click to view] "EverQuest" <webforumsuser@macromedia.com> wrote in message news:c20glk$7g6$1@forums.macromedia.com... > I'm not sure if my solution will work for you, as I only wanted the partent > clip to define onRollOver and OnRollOut functions, but not onPress, onRelease, > etc.... > > I'm not proud of this solutions, but, it works. Here it is in a nutshell.... > > I created a clip called p1_mc. It is the parent movie clip. It's only > function is to contain/attach the child movie clips. It defines no event > handlers. > > Below/Within p1_mc, I created 3 child clips... > > I created a clip called c1_mc to cycle through text (a new display every 30 > seconds). That is it's only function. It has a depth of 100 (the bottom > clip). When the user moves the mouse over this text, I want the text to shift > up and buttons to appear. > > I created a clip called c2_mc to hold buttons that, when released, move the > text either forward or backwards. The alpha is initially set to 0. It has a > depth of 200 (the middle clip, initially). > > I created a clip called c3_mc. It is transparent. When the text field is > updated, it is sized/moved to cover both the text field and the buttons. It > has a depth of 300 (the top clip, initially). I defined an onRollOver event to > 1) Swap depth levels with c2_mc (the buttons clip), allowing mouse events on > that clip. 2) Disable itself (disables all mouse events on c3_mc). 3) Define > an onFrame which, frame by frame, pushes the text up and fades in the buttons. > When the onFrame detects that the text is full up and the buttons are there, > it deletes itself and queues a check routine to run every .2 seconds to verify > that the mouse is still within the text/button area (c3_mc). When the check > routine detects that the mouse has moved out of the area, another onFrame is > defined to pull the text down and fade the buttons out. After this is done, > the onframe moves c3_mc back to the top level (swaps depth with c2_mc), > enables itself so it can detect onRollOver events, and then deletes the current > onFrame event. > > Note that you can not define an onRollOut for c3_mc because that would either > block events to clips underneath it or it would fire the onRollOut when you > roll onto one of the buttons (if it were underneath the buttons)..... > > Not elegant or pretty, but it works... > > If anyone knows of a better way, please detail!...... > > >
I'm not sure if my solution will work for you, as I only wanted the partent clip to define onRollOver and OnRollOut functions, but not onPress, onRelease, etc.... I'm not proud of this solutions, but, it works. Here it is in a nutshell.... I created a clip called p1_mc. It is the parent movie clip. It's only function is to contain/attach the child movie clips. It defines no event handlers. Below/Within p1_mc, I created 3 child clips... I created a clip called c1_mc to cycle through text (a new display every 30 seconds). That is it's only function. It has a depth of 100 (the bottom clip). When the user moves the mouse over this text, I want the text to shift up and buttons to appear. I created a clip called c2_mc to hold buttons that, when released, move the text either forward or backwards. The alpha is initially set to 0. It has a depth of 200 (the middle clip, initially). I created a clip called c3_mc. It is transparent. When the text field is updated, it is sized/moved to cover both the text field and the buttons. It has a depth of 300 (the top clip, initially). I defined an onRollOver event to 1) Swap depth levels with c2_mc (the buttons clip), allowing mouse events on that clip. 2) Disable itself (disables all mouse events on c3_mc). 3) Define an onFrame which, frame by frame, pushes the text up and fades in the buttons. When the onFrame detects that the text is full up and the buttons are there, it deletes itself and queues a check routine to run every .2 seconds to verify that the mouse is still within the text/button area (c3_mc). When the check routine detects that the mouse has moved out of the area, another onFrame is defined to pull the text down and fade the buttons out. After this is done, the onframe moves c3_mc back to the top level (swaps depth with c2_mc), enables itself so it can detect onRollOver events, and then deletes the current onFrame event. Note that you can not define an onRollOut for c3_mc because that would either block events to clips underneath it or it would fire the onRollOut when you roll onto one of the buttons (if it were underneath the buttons)..... Not elegant or pretty, but it works... If anyone knows of a better way, please detail!......
Don't see what you're looking for? Try a search.
|
|
|