Skip to content

Instantly share code, notes, and snippets.

View alecmce's full-sized avatar

Alec McEachran alecmce

View GitHub Profile
@alecmce
alecmce / EnterFrameDispatcher.as
Created November 26, 2009 22:19
A strategy for creating an application 'enter-frame' signal in AS3
package
{
import org.osflash.signals.Signal;
import flash.display.MovieClip;
import flash.events.Event;
import flash.utils.getDefinitionByName;
/**
* The EnterFrameDispatcher is injected into the Main class through the [Frame] MetaData tag.
package performancetests
{
import flash.events.Event;
public class EventsTest
{
private const COMPLETE:String = Event.COMPLETE;
public var iterations:uint = 5;
package performancetests
{
import flash.events.Event;
public class CapturedEventsTest
{
private const COMPLETE:String = Event.COMPLETE;
public var iterations:uint = 5;
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.events.Event;
/**
* A pretty quick implementation of Conway's Game Of Life
*
* @author Alec McEachran
package
{
import flash.display.Sprite;
import flash.events.Event;
import flash.text.TextField;
public class EnterFrameIsConfusing extends Sprite
{
private var output:TextField;
// meh...
var iAmAStringInstance :String = "";
var iAmANullString :String = null;
if(iAmAStringInstance)
{
trace("iAmAStringInstance is neither null nor empty");
}
else
var ray:Ray3D = new Ray3D(0, 0, -140, 0, 0, 100);
var sphere:Sphere3D = new Sphere3D(40, 0, 0, 0);
var alpha:Number = sphere.intersectRay(ray);
trace(alpha);
// outputs 0.6428719030100183
// hex definition
public static const FLAG_1:uint = 0x1;
public static const FLAG_2:uint = 0x2;
public static const FLAG_3:uint = 0x4;
public static const FLAG_4:uint = 0x8;
public static const FLAG_5:uint = 0x10;
public static const FLAG_6:uint = 0x20;
public static const FLAG_7:uint = 0x40;
public static const FLAG_8:uint = 0x80;
package ;
import flash.display.Sprite;
import flash.display.BitmapData;
import flash.display.Bitmap;
import flash.utils.ByteArray;
import flash.utils.Endian;
def inspect(dir)
Dir.foreach(dir) do |subdir|
if (FileTest.directory?(subdir))
inspect(subdir)
end
end
do_something_interesting_with_directory(dir)
end