Here’s some neat coding developed by senocular (thanks a lot!), that “allows child clips to receive events despite the fact that a parent might make use of them as well, something not possible with the normal convention of handling button events where no child movie clip ever receives button events if a parent has any button event handlers defined for it.”
Yeah! It’s neat.
But I can’t really figure out how to attach an event to an mc called “child_next” within “parent1”.
Can anybody help me out?
import com.senocular.events.*
function handleEventMethod(eventObject:ButtonEvent):Void {
// trace event
if (eventObject.type != "onMouseWithin") trace(eventObject.type +"("+this+")");
// stop event from bubbling up to parent clips if this clip is parent2.child
if (this.target == parent2.child) eventObject.stopPropagation();
// react based on which event is being received.
switch(eventObject.type){
case "onRollOver":
case "onDragOver":
// this.target.gotoAndStop(2);
this.target.play();
break;
case "onDragOut":
case "onRollOut":
case "onReleaseOutside":
// this.target.gotoAndStop(1);
this.target.play();
break;
case "onMouseWithin":
break;
//
}
}
// clips to receive events from ButtonEventHandler
var clips:Array = [parent1, parent1.child_prev, parent1.child_next];
var clip:MovieClip;
var buttonEventObj:ButtonEvent;
// allow events to pass through despite overlapping
ButtonEventHandler.overlapBlocksEvents = false;
// assign handleEventMethod as handleEvent handler for each clip in clips
for (clip in clips) {
// get ButtonEvent object for each clip and assign handleEvent function
buttonEventObj = ButtonEventHandler.getEventObject(clips[clip]);
buttonEventObj.handleEvent = handleEventMethod;
// for parent1, set overlapping to block events
if (clips[clip] == parent1) buttonEventObj.overlapBlocksEvents = true;
// enable the hand cursor by providing a null onPress event handler
clips[clip].onPress = null;
}