fn handle_clip_event(
        &self,
        context: &mut UpdateContext<'_, 'gc, '_>,
        event: ClipEvent,
    ) -> ClipEventResult {
        if !self.visible() {
            return ClipEventResult::NotHandled;
        }

        if !self.enabled() && !matches!(event, ClipEvent::KeyPress { .. }) {
            return ClipEventResult::NotHandled;
        }

        if event.propagates() {
            for child in self.iter_execution_list() {
                if child.handle_clip_event(context, event) == ClipEventResult::Handled {
                    return ClipEventResult::Handled;
                }
            }
        }

        let mut handled = ClipEventResult::NotHandled;
        let self_display_object = (*self).into();
        let mut write = self.0.write(context.gc_context);

        // Translate the clip event to a button event, based on how the button state changes.
        let cur_state = write.state;
        let new_state = match event {
            ClipEvent::RollOut => ButtonState::Up,
            ClipEvent::RollOver => ButtonState::Over,
            ClipEvent::Press => ButtonState::Down,
            ClipEvent::Release => ButtonState::Over,
            ClipEvent::KeyPress { key_code } => {
                handled = write.run_actions(
                    context,
                    swf::ButtonActionCondition::KEY_PRESS,
                    Some(key_code),
                );
                cur_state
            }
            _ => return ClipEventResult::NotHandled,
        };

        match (cur_state, new_state) {
            (ButtonState::Up, ButtonState::Over) => {
                write.run_actions(context, swf::ButtonActionCondition::IDLE_TO_OVER_UP, None);
                write.play_sound(context, write.static_data.read().up_to_over_sound.as_ref());
            }
            (ButtonState::Over, ButtonState::Up) => {
                write.run_actions(context, swf::ButtonActionCondition::OVER_UP_TO_IDLE, None);
                write.play_sound(context, write.static_data.read().over_to_up_sound.as_ref());
            }
            (ButtonState::Over, ButtonState::Down) => {
                write.run_actions(
                    context,
                    swf::ButtonActionCondition::OVER_UP_TO_OVER_DOWN,
                    None,
                );
                write.play_sound(
                    context,
                    write.static_data.read().over_to_down_sound.as_ref(),
                );
            }
            (ButtonState::Down, ButtonState::Over) => {
                write.run_actions(
                    context,
                    swf::ButtonActionCondition::OVER_DOWN_TO_OVER_UP,
                    None,
                );
                write.play_sound(
                    context,
                    write.static_data.read().down_to_over_sound.as_ref(),
                );
            }
            _ => (),
        };

        // Queue ActionScript-defined event handlers after the SWF defined ones.
        // (e.g., clip.onRelease = foo).
        if context.swf.version() >= 6 {
            if let Some(name) = event.method_name() {
                context.action_queue.queue_actions(
                    self_display_object,
                    ActionType::Method {
                        object: write.object.unwrap(),
                        name,
                        args: vec![],
                    },
                    false,
                );
            }
        }

        if write.state != new_state {
            drop(write);
            self.set_state(context, new_state);
        }

        handled
    }
/// Executes and propagates the given clip event.
/// Events execute inside-out; the deepest child will react first, followed by its parent, and
/// so forth.
Executes and propagates the given clip event.
Events execute inside-out; the deepest child will react first, followed by its parent, and
so forth.
Executes and propagates the given clip event . Events execute inside - out ; the deepest child will react first followed by its parent and so forth .
fn handle_clip_event(
        &self,
        context: &mut UpdateContext<'_, 'gc, '_>,
        event: ClipEvent,
    ) -> ClipEventResult {
        if !self.visible() {
            return ClipEventResult::NotHandled;
        }
        if !self.enabled() && !matches!(event, ClipEvent::KeyPress { .. }) {
            return ClipEventResult::NotHandled;
        }
        if event.propagates() {
            for child in self.iter_execution_list() {
                if child.handle_clip_event(context, event) == ClipEventResult::Handled {
                    return ClipEventResult::Handled;
                }
            }
        }
        let mut handled = ClipEventResult::NotHandled;
        let self_display_object = (*self).into();
        let mut write = self.0.write(context.gc_context);
        // Translate the clip event to a button event, based on how the button state changes.
        let cur_state = write.state;
        let new_state = match event {
            ClipEvent::RollOut => ButtonState::Up,
            ClipEvent::RollOver => ButtonState::Over,
            ClipEvent::Press => ButtonState::Down,
            ClipEvent::Release => ButtonState::Over,
            ClipEvent::KeyPress { key_code } => {
                handled = write.run_actions(
                    context,
                    swf::ButtonActionCondition::KEY_PRESS,
                    Some(key_code),
                );
                cur_state
            }
            _ => return ClipEventResult::NotHandled,
        };
        match (cur_state, new_state) {
            (ButtonState::Up, ButtonState::Over) => {
                write.run_actions(context, swf::ButtonActionCondition::IDLE_TO_OVER_UP, None);
                write.play_sound(context, write.static_data.read().up_to_over_sound.as_ref());
            }
            (ButtonState::Over, ButtonState::Up) => {
                write.run_actions(context, swf::ButtonActionCondition::OVER_UP_TO_IDLE, None);
                write.play_sound(context, write.static_data.read().over_to_up_sound.as_ref());
            }
            (ButtonState::Over, ButtonState::Down) => {
                write.run_actions(
                    context,
                    swf::ButtonActionCondition::OVER_UP_TO_OVER_DOWN,
                    None,
                );
                write.play_sound(
                    context,
                    write.static_data.read().over_to_down_sound.as_ref(),
                );
            }
            (ButtonState::Down, ButtonState::Over) => {
                write.run_actions(
                    context,
                    swf::ButtonActionCondition::OVER_DOWN_TO_OVER_UP,
                    None,
                );
                write.play_sound(
                    context,
                    write.static_data.read().down_to_over_sound.as_ref(),
                );
            }
            _ => (),
        };
        // Queue ActionScript-defined event handlers after the SWF defined ones.
        // (e.g., clip.onRelease = foo).
        if context.swf.version() >= 6 {
            if let Some(name) = event.method_name() {
                context.action_queue.queue_actions(
                    self_display_object,
                    ActionType::Method {
                        object: write.object.unwrap(),
                        name,
                        args: vec![],
                    },
                    false,
                );
            }
        }
        if write.state != new_state {
            drop(write);
            self.set_state(context, new_state);
        }
        handled
    }
fn handle_clip_event ( & self , context : & mut UpdateContext < ' _ , ' gc , ' _ > , event : ClipEvent , ) -> ClipEventResult { if ! self . visible ( ) { return ClipEventResult :: NotHandled ; } if ! self . enabled ( ) && ! matches ! ( event ClipEvent KeyPress { } ) { return ClipEventResult :: NotHandled ; } if event . propagates ( ) { for child in self . iter_execution_list ( ) { if child . handle_clip_event ( context , event ) == ClipEventResult :: Handled { return ClipEventResult :: Handled ; } } } let mut handled = ClipEventResult :: NotHandled ; let self_display_object = ( * self ) . into ( ) ; let mut write = self . 0 . write ( context . gc_context ) ; // Translate the clip event to a button event, based on how the button state changes. let cur_state = write . state ; let new_state = match event { ClipEvent :: RollOut => ButtonState :: Up , ClipEvent :: RollOver => ButtonState :: Over , ClipEvent :: Press => ButtonState :: Down , ClipEvent :: Release => ButtonState :: Over , ClipEvent :: KeyPress { key_code } => { handled = write . run_actions ( context , swf :: ButtonActionCondition :: KEY_PRESS , Some ( key_code ) , ) ; cur_state } _ => return ClipEventResult :: NotHandled , } ; match ( cur_state , new_state ) { ( ButtonState :: Up , ButtonState :: Over ) => { write . run_actions ( context , swf :: ButtonActionCondition :: IDLE_TO_OVER_UP , None ) ; write . play_sound ( context , write . static_data . read ( ) . up_to_over_sound . as_ref ( ) ) ; } ( ButtonState :: Over , ButtonState :: Up ) => { write . run_actions ( context , swf :: ButtonActionCondition :: OVER_UP_TO_IDLE , None ) ; write . play_sound ( context , write . static_data . read ( ) . over_to_up_sound . as_ref ( ) ) ; } ( ButtonState :: Over , ButtonState :: Down ) => { write . run_actions ( context , swf :: ButtonActionCondition :: OVER_UP_TO_OVER_DOWN , None , ) ; write . play_sound ( context , write . static_data . read ( ) . over_to_down_sound . as_ref ( ) , ) ; } ( ButtonState :: Down , ButtonState :: Over ) => { write . run_actions ( context , swf :: ButtonActionCondition :: OVER_DOWN_TO_OVER_UP , None , ) ; write . play_sound ( context , write . static_data . read ( ) . down_to_over_sound . as_ref ( ) , ) ; } _ => ( ) , } ; // Queue ActionScript-defined event handlers after the SWF defined ones. // (e.g., clip.onRelease = foo). if context . swf . version ( ) >= 6 { if let Some ( name ) = event . method_name ( ) { context . action_queue . queue_actions ( self_display_object , ActionType :: Method { object : write . object . unwrap ( ) , name , args : vec ! [ ] , } , false , ) ; } } if write . state != new_state { drop ( write ) ; self . set_state ( context , new_state ) ; } handled }
Executes and propagates the given clip event.
Executes and propagates the given clip event .
&self
context
&mut UpdateContext<'_, 'gc, '_>
event
ClipEvent
&self
context
&mut UpdateContext<'_, 'gc, '_>
event
ClipEvent