Más contenido relacionado La actualidad más candente (20) Similar a 2011 07-hiyoko (20) 2011 07-hiyoko4. Flash Event
Events
2011 7 2
5. Event
Event
Event
2011 7 2
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. 01 Sample
addEventListener(Event.EXIT_FRAME, onLoop);
removeEventListener(Event.EXIT_FRAME, onLoop);
2011 7 2
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. 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. 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. 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
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. 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. Signals
if (stage)
init();
else
new NativeSignal(this,
Event.ADDED_TO_STAGE,
Event
).addOnce(init);
init
2011 7 2
16. Signals
var accelerate:Signal = new Signal(Number);
accelerate.dispatch(speed);
function onAccelerate(speed:Number) {
}
accelerate.add(onAccelerate);
2011 7 2
17. Signals
NativeSignal
Signal
DeluxeSignal
Class
2011 7 2
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. 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/signals
2011 7 2