Skip to content

Instantly share code, notes, and snippets.

View alecmce's full-sized avatar

Alec McEachran alecmce

View GitHub Profile
package alecmce.ui.misc
{
import flash.display.Graphics;
import flash.display.GraphicsPath;
import flash.geom.Rectangle;
public class Scribble
{
public var spacing:Number;
public var thickness:Number;
var list:Vector.<Point> = new Vector.<Point>();
list[0] = new Point(1, 1);
list[1] = new Point(-1, 1);
list[2] = new Point(-1, -1);
list[3] = new Point(1, -1);
var polygon:Polygon = new Polygon(list);
// INTERPRETATION 1:
// polygon is defined by vertices and represents a square the sides of which lie parallel
package
{
import com.bit101.components.PushButton;
import flash.display.BitmapData;
import flash.display.Sprite;
import flash.display.StageDisplayState;
import flash.events.MouseEvent;
import flash.text.TextField;
import flash.text.TextFormat;
@alecmce
alecmce / Anim.as
Created November 12, 2010 05:47
An animation interface - for discussion
package alecmce.anim
{
import org.osflash.signals.ISignal;
/**
* Describes an Animation in general terms.
*/
public interface Anim
{
@alecmce
alecmce / LZMA.as
Created February 25, 2011 09:22
LZMA class
/**
* consolidate the LZMA encoder and decoders from @joa and @inspirit
*/
package
{
import apparat.lzma.LZMADecoder;
import ru.inspirit.lzma.LZMAEncoder;
import flash.utils.ByteArray;
@alecmce
alecmce / two-asserts-in-test.as
Created June 1, 2011 15:46
I don't understand why one assert per test is superior
// the code
class eg
{
public var width:int;
public var height:int;
public function eg(width:int, height:int)
{
this.width = width;
@alecmce
alecmce / signal-cake.as
Created June 3, 2011 16:04
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);
@alecmce
alecmce / puremvc-mediator-snippet.as
Created July 4, 2011 14:35
PureMVC Mediator extension
private var _view:IView;
private var _notifications:Array;
final protected function registerObserver(notificationName:String, closure:Function):void
{
_view ||= View.getInstance();
_view.registerObserver(notificationName, new Observer(closure, this));
(_notifications ||= []).push(notificationName);
}
@alecmce
alecmce / worstcode2011awards.as
Created July 13, 2011 15:18
what is wrong with this picture?
private var index;
private function loadPanels():void
{
for (var i:Number = 0; i < PANELS.length; i++)
{
index = i;
loadPanel();
}
}
@alecmce
alecmce / signals_problem.as
Created July 17, 2011 16:11
problem for signals?
/**
* This example sets up an asynchronous process that will complete with a
* complete signal
*/
public class Example
{
private var _complete:Signal;
public function Example()
{