Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Signalsで Event処理を簡単に

2,042 views

Published on

2011-07-02 福岡ひよこの会発表資料

Published in: Technology, Business
  • Be the first to comment

  • Be the first to like this

Signalsで Event処理を簡単に

  1. 1. www.inazumatv.com/contents/ me.beginsprite.com2011 7 2
  2. 2. www.sidevision.co.jp2011 7 2
  3. 3. Signals Event2011 7 2
  4. 4. Flash Event Events2011 7 2
  5. 5. Event Event Event2011 7 2
  6. 6. 01 Sample start_btn.addEventListener(MouseEvent.CLICK, onStartClicked); stop_btn.addEventListener(MouseEvent.CLICK, onStopClicked); function onStartClicked (e:MouseEvent):void { addEventListener(Event.EXIT_FRAME, onLoop); } function onStopClicked (e:MouseEvent):void { removeEventListener(Event.EXIT_FRAME, onLoop); } function onLoop (e:Event):void { fan_mc.rotation += 5; }2011 7 2
  7. 7. 01 Sample addEventListener(Event.EXIT_FRAME, onLoop); removeEventListener(Event.EXIT_FRAME, onLoop);2011 7 2
  8. 8. 02 Sample package com.inazumatv.events { import flash.events.Event; public class FanEvent extends Event { public static const FAN_START:String = "fanStart"; public static const FAN_STOP:String = "fanStop"; public function FanEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false) { super(type, bubbles, cancelable); } override public function clone():Event { return new FanEvent(type, bubbles, cancelable); } } }2011 7 2
  9. 9. 02 Sample package com.inazumatv.events { import flash.events.Event; public class FanEvent extends Event { public static const FAN_START:String = "fanStart"; public static const FAN_STOP:String = "fanStop"; public function FanEvent(type:String, bubbles:Boolean=true, cancelable:Boolean=false) { super(type, bubbles, cancelable); } override public function clone():Event { return new FanEvent(type, bubbles, cancelable); } } }2011 7 2
  10. 10. 03 Sample package com.inazumatv.events { import flash.events.Event; public class FanSpeedEvent extends Event { public static const CHANGE_SPEED:String = "changeSpeed"; private var _speed:Number; public function FanSpeedEvent(speed:Number, type:String, bubbles:Boolean=true, cancelable:Boolean=false) { _speed = speed; super(type, bubbles, cancelable); } override public function clone():Event { return new FanSpeedEvent(speed, type, bubbles, cancelable); } override public function toString():String { return formatToString("FanSpeedEvent", "speed", "type", "bubbles", "cancelable", "eventPhase") } public function get speed():Number { return _speed; } } }2011 7 2
  11. 11. 03 Sample package com.inazumatv.events { import flash.events.Event; public class FanSpeedEvent extends Event { public static const CHANGE_SPEED:String = "changeSpeed"; private var _speed:Number; public function FanSpeedEvent(speed:Number, type:String, bubbles:Boolean=true, cancelable:Boolean=false) { _speed = speed; super(type, bubbles, cancelable); } override public function clone():Event { return new FanSpeedEvent(speed, type, bubbles, cancelable); } override public function toString():String { return formatToString("FanSpeedEvent", "speed", "type", "bubbles", "cancelable", "eventPhase") } public function get speed():Number { return _speed; } } }2011 7 2
  12. 12. Signals Event2011 7 2
  13. 13. Signals addEventListener(listener:Function) removeEventListener(listener:Function) dispatchEvent(new ExampleEvent(ExampleEvent.EVENT_TYPE)) add(listener:Function) addOnce(listener:Function) remove(listener:Function) removeAll() dispatch(... valueObjects)2011 7 2
  14. 14. Signals add(listener:Function) addOnce(listener:Function) remove(listener:Function) removeAll() dispatch(... valueObjects) addWithPriority(listener:Function, priority:int=0) addOnceWithPriority(listener:Function, priority:int=0)2011 7 2
  15. 15. Signals if (stage) init(); else new NativeSignal(this, Event.ADDED_TO_STAGE, Event ).addOnce(init); init2011 7 2
  16. 16. Signals var accelerate:Signal = new Signal(Number); accelerate.dispatch(speed); function onAccelerate(speed:Number) { } accelerate.add(onAccelerate);2011 7 2
  17. 17. Signals NativeSignal Signal DeluxeSignal Class2011 7 2
  18. 18. Signals github : as3-signals https://github.com/robertpenner/as3-signals Robert Penner Programming Macromedia Flash MX mx.motion.easing.* fl.motion.easing.*2011 7 2
  19. 19. Signals github : as3-signals https://github.com/robertpenner/as3-signals/wiki https://github.com/robertpenner/as3-signals/wiki/_pages http://www.himco.jp/articles.php inzumatv.com http://www.inazumatv.com/contents/archives/tag/signals2011 7 2
  20. 20. www.inazumatv.com/contents/ me.beginsprite.com www.sidevision.co.jp @taikiken2011 7 2

×