Groups | Blog | Home
all groups > flash actionscript > april 2007 >

flash actionscript : onPress Issue


BeniRose
4/18/2007 9:19:15 PM
I'm having a problem with my onPress being triggered. I have a parent MC, let's
hypothetically call it "sections". It has a bunch of MCs in it, let's say by
the name of "section_1", "section_2", "section_3". On the first frame of the
first and only layer inside my parent MC (sections) I have a bunch of onPress
code for my children section. It worked great until I added an onPress code for
my parent MC on my _root timeline. Now only my parent's onPress code is being
triggered, and the onPress for the children aren't. Is there anyway to get
these both to be triggered, perhaps with a mouse listener?
kglad
4/18/2007 9:59:00 PM
the parent movieclip is intercepting mouse events so the child movieclips do
not detect mouse events.

to remedy, you must either code for the youngest generation that needs mouse
handlers or use a hitTest for one of the generations.
Spray27
4/18/2007 10:26:51 PM
I'm having a similar problem, where a "play_mc", "stop_mc", "pause_mc" are
nested inside a "controls_mc" to fade everything in and out on
controls_mc.onRollOver.

Could you further explain the hitTest and "coding for the youngest
generation"? It will be greatly appreciated.
kglad
4/18/2007 10:52:12 PM
hitTest technique:



_level0.onMouseMove=function(){
if(parentMC.hitTest(_xmouse,_ymouse){
// execute parent movieclip onPress code
}
}
childMC.onPress=function(){
// execute child movieclip onPress code
}

// coding for youngest generation: on the parent mc timeline (where the child
mc's can be found) create a shape that's the same as the parent movieclip less
the children mcs. paste that on the parent's timeline, convert to a movieclip
and assign mouse handlers and, if you want the children to execute the same
code as the parent, to also contain that code add the same code to their
handlers.
Trevor McCauley - Adobe
4/20/2007 12:22:42 PM
also see:
http://www.senocular.com/flash/tutorials/buttoncapturing/



[quoted text, click to view]

kglad
4/20/2007 8:04:48 PM
AddThis Social Bookmark Button