Date post: | 25-May-2015 |
Category: |
Technology |
Upload: | hiroaki-okubo |
View: | 642 times |
Download: | 0 times |
おおくぼ ひろあきInteractive Designer
www.inazumatv.com/contents/
me.beginsprite.com
2011年7月2日土曜日
SignalsでEvent処理を簡単に
2011年7月2日土曜日
FlashはEventで動くEvents処理は必須
でもコレかなり面倒くさい
2011年7月2日土曜日
Eventの使い方Eventにリスナー(関数)を追加関数を定義
必要なくなったらEventからリスナーを削除する
2011年7月2日土曜日
01 Sample fan_mc
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日土曜日
01 Sample
addEventListener(Event.EXIT_FRAME, onLoop);
removeEventListener(Event.EXIT_FRAME, onLoop);
ボタンから直接Event操作
2011年7月2日土曜日
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日土曜日
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); }}}
カスタムイベントを作るのは面倒くさい
Event Type 定数
clone を override
2011年7月2日土曜日
03 Samplepackage 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日土曜日
03 Samplepackage 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; }}}
カスタムイベントに引数
Event Type 定数
clone を override
toString を override
もっと面倒くさい
変数をread可能へ
2011年7月2日土曜日
だからSignalsで
Event処理を簡単に
2011年7月2日土曜日
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日土曜日
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日土曜日
Signalsを使うとif (stage) init();else new NativeSignal(this, Event.ADDED_TO_STAGE, Event
).addOnce(init);
init関数でremoveの必要がない
2011年7月2日土曜日
Signalsを使うとvar accelerate:Signal = new Signal(Number);accelerate.dispatch(speed);
function onAccelerate(speed:Number) {}accelerate.add(onAccelerate);
カスタムイベントがいらない
2011年7月2日土曜日
Signals
NativeSignal SignalDeluxeSignal
主要(だと思う)Class
2011年7月2日土曜日
Signals
Robert Penner Programming Macromedia Flash MX
mx.motion.easing.*fl.motion.easing.*OOPでスクリプトTween, easing, 3D, Color Transform...etc
github : as3-signalshttps://github.com/robertpenner/as3-signals
2011年7月2日土曜日
Signals 参考サイトgithub : as3-signalshttps://github.com/robertpenner/as3-signals/wikihttps://github.com/robertpenner/as3-signals/wiki/_pages
ヒムカンパニーhttp://www.himco.jp/articles.php
inzumatv.comhttp://www.inazumatv.com/contents/archives/tag/signals
2011年7月2日土曜日
おおくぼ ひろあき@taikiken
www.inazumatv.com/contents/
me.beginsprite.com
www.sidevision.co.jp
2011年7月2日土曜日