Skip to content

Instantly share code, notes, and snippets.

View Stray's full-sized avatar

Stray Stray

  • Innerleithen, Scotland
View GitHub Profile
@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 / 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 / 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 / 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 / TestSignalCommandMapUnmapping.as
Created March 15, 2011 16:45
A test that should fail in the SignalCommandMap
[Test(expects="org.swiftsuspenders.InjectorError")]
public function signal_values_no_longer_persist_from_one_to_the_next():void
{
var propOne:TestCommandProperty = new TestCommandProperty();
var propTwo:TestCommandProperty2 = new TestCommandProperty2();
signalCommandMap.mapSignal(onePropSignal, TestOnePropertyCommand);
var secondPropSignal:TestCommandProperty2Signal = new TestCommandProperty2Signal();
// this command requires the values dispatched by both signals
@Stray
Stray / ProblemFunctionsInSignalCommandMap.as
Created March 15, 2011 16:59
Problem functions in SignalCommandMap
protected function mapSignalValues(valueClasses:Array, valueObjects:Array):void {
for (var i:uint = 0; i < valueClasses.length; i++) {
injector.mapValue(valueClasses[i], valueObjects[i]);
}
}
protected function unmapSignalValues(valueClasses:Array, valueObjects:Array):void {
for (var i:uint = 0; i < valueClasses.length; i++) {
injector.unmap(valueClasses[i], valueObjects[i]);
}
@Stray
Stray / MappingUnmappingInjector.as
Created March 15, 2011 17:00
The Mapping and Unmapping functions in the Injector aren't symmetrical
function mapValue(whenAskedFor:Class, useValue:Object, named:String = ""):*;
function unmap(clazz:Class, named:String = ""):void;
@Stray
Stray / Context.as
Created April 3, 2011 14:59
Robotlegs Context with injection unmapping when contextView property is set, to prevent warnings in SS 1.6
/*
* Copyright (c) 2009 the original author or authors
*
* Permission is hereby granted to use, modify, and distribute this file
* in accordance with the terms of the license agreement accompanying it.
*/
package org.robotlegs.mvcs
{
import flash.display.DisplayObjectContainer;
@Stray
Stray / ExampleUsage.as
Created July 5, 2011 11:39
Fluent filter for a collection of users
requiredUsers = new UserDataVOFilter(allUsers)
.onlyManagers()
.withCompanyKey(3)
.withStatus(UserStatus.STAFF)
.data;
@Stray
Stray / ResourcePromise.as
Created February 24, 2012 16:50
Example of promise
package modules.common.net
{
import flash.display.DisplayObject;
import org.osflash.signals.Signal;
public class ResourcePromise implements IPromise, IResourcePromise
{
protected var _result:DisplayObject;
protected var _errorMessage:String;
protected var _loaded:Signal = new Signal(DisplayObject);