Custom Event With Parameter


/ Published in: ActionScript 3
Save to your folder(s)



Copy this code and paste it in your HTML
  1. package ch.pfeisinger.snipplr.view.events {
  2. import flash.events.Event;
  3.  
  4. /**
  5. * @author Pfeisinger Markus
  6. */
  7.  
  8. public class SoundstatusEvent extends Event
  9. {
  10. public static const SOUNDCHANGED:String = "soundChanged";
  11. public var soundOn:Boolean;
  12.  
  13. public function SoundstatusEvent(soundIsOn:Boolean)
  14. {
  15. super(SOUNDCHANGED);
  16. soundOn = soundIsOn;
  17. }
  18. }
  19. }
  20.  
  21.  
  22. USAGE for PureMVC:
  23.  
  24. Component(MovieClip) dispatches Event:
  25. --------------------------------------
  26. dispatchEvent(new SoundstatusEvent(false));
  27.  
  28. Mediator listens for event:
  29. --------------------------
  30. component.addEventListener(SoundstatusEvent.SOUNDCHANGED, onSoundbuttonClicked);
  31.  
  32. private function onSoundbuttonClicked(event:SoundstatusEvent):void
  33. {
  34. trace("Mediator:: onSoundbuttonClicked() "+event.soundOn);
  35. sendNotification(ApplicationFacade.SOUNDSTATUS_CHANGED, event.soundOn as Boolean);
  36. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.