Skip to content

Instantly share code, notes, and snippets.

View Stray's full-sized avatar

Stray Stray

  • Innerleithen, Scotland
View GitHub Profile
@Stray
Stray / SignalMap.as
Created March 9, 2011 17:03
Use instead of the eventMap in robotlegs mediators
package org.robotlegs.mvcs
{
import org.osflash.signals.ISignal;
import flash.utils.Dictionary;
public class SignalMap implements ISignalMap
{
protected var _handlersBySignal:Dictionary;
public function SignalMap()
@Stray
Stray / ConditionalsGone.as
Created January 29, 2011 20:35
New implementation gets rid of the conditionals
protected function selectedHandler(option:IBudgetGameOption, vo:BudgetGameOptionVO):void
{
enable(vo.enables);
disable(vo.disables);
dispatchUpdate(vo.cost, vo.productivity);
}
protected function enable(option:IDisableable):void
{
option.enable();
@Stray
Stray / IDisableable.as
Created January 29, 2011 20:25
Simpler interface that only provides what's needed
public interface IDisableable
{
function enable():void;
function disable():void;
}
@Stray
Stray / NullBudgetGameOption.as
Created January 29, 2011 19:56
First attempt to implement NullBudgetGameOption
public class NullBudgetGameOption
{
public function NullBudgetGameOption()
{
}
public function select():void { }
public function deselect():void { }
@Stray
Stray / IBudgetGameOption1.as
Created January 29, 2011 19:52
First version of the BudgetGameOption interface
public interface IBudgetGameOption
{
function select():void;
function deselect():void;
function enable():void;
function disable():void;
@Stray
Stray / YukkyConditionalCode.as
Created January 29, 2011 19:42
Look at those conditionals! Gross!
protected function selectedHandler(option:IBudgetGameOption, vo:BudgetGameOptionVO):void
{
enable(vo.enables);
disable(vo.disables);
dispatchUpdate(vo.cost, vo.productivity);
}
protected function enable(option:IBudgetGameOption):void
{
if(option != null)
@Stray
Stray / InterestingEventTypesLookup.as
Created January 19, 2011 21:42
The actual service - map as a singleton and use getInstance to make it come to life
public class InterestingEventTypesLookup {
protected var _eventClassesByType:Dictionary;
public function get eventClassesByType():Dictionary
{
return _eventClassesByType ||= new Dictionary();
}
public function appendEventInterest(eventClass:Class, eventType:String):void
@Stray
Stray / TogglePanelPositionLinkedList.as
Created January 19, 2011 13:41
Toggle the position of a panel by linked list (for comparison with other approaches)
private var _currentTargetPosition:LinkedListPoint;
private function createPositionTargets():void
{
var onPosition:LinkedListPoint = new LinkedListPoint(0, ON_STAGE_Y, null);
var offPosition:LinkedListPoint = new LinkedListPoint(0, OFF_STAGE_Y, onPosition);
onPosition.next = offPosition;
_currentTargetPosition = offPosition;
}
@Stray
Stray / LinkedListPoint.as
Created January 19, 2011 13:31
An extension of Point for LinkedList implementation
package animation.geom
{
import flash.geom.Point;
public class LinkedListPoint extends Point
{
public var next:LinkedListPoint;
public function LinkedListPoint(x:Number, y:Number, nextPoint:LinkedListPoint)
{
@Stray
Stray / TogglePanelPositionHandlers.as
Created January 19, 2011 13:11
Toggle the position of a panel by decoupled handlers (for comparison with other approaches)
private var _nextMotion:Function = revealPanel;
private function togglePanelPosition(e:MouseEvent):void
{
_nextMotion();
}
private function revealPanel():void
{
moveTo(ON_STAGE_Y);