Skip to content

Instantly share code, notes, and snippets.

@alecmce
Created June 3, 2011 16:04
Show Gist options
  • Save alecmce/1006588 to your computer and use it in GitHub Desktop.
Save alecmce/1006588 to your computer and use it in GitHub Desktop.
Can I have my signal cake and eat it too?
class NoCake
{
private var _clicked:Signal;
private var _data:Object;
public function NoCake(mc:MovieClip, data:Object)
{
_clicked = new Signal(Object);
_data = data;
mc.addEventListener(MouseEvent.CLICK, onClick);
}
private function onClick(event:MouseEvent):void
{
_clicked.dispatch(data);
}
public function get clicked():ISignal
{
return _clicked;
}
}
public class Cake
{
private var _clicked:CakeSignal;
public function NoCake(mc:MovieClip, data:Object)
{
_clicked = new CakeSignal(mc, MouseEvent.CLICK, _data);
}
public function get clicked():ISignal
{
return _clicked;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment