Skip to content

Instantly share code, notes, and snippets.

@Draknek
Draknek / Main.as
Created January 21, 2011 16:21
Minimal AS3 project
package
{
import flash.display.*;
[SWF(width = "640", height = "480")]
public class Main extends Sprite
{
public function Main ()
{
graphics.beginFill(0x000000);
@Draknek
Draknek / gist:805842
Created February 1, 2011 13:24
Riddle for SoManyRooms
12 people next to 12 numbered doors. A sign saying that there is one and only one safe door to exit.
Talking to each of the people they will tell you:
1) The safe door is either 1, 2, 3 or 4
2) All even numbers tell the truth
3) All multiples of 3 are liars
4) The safe door is either 4, 5, 6 or 7
5) #4 is telling the truth
6) All odd numbers are lying
@Draknek
Draknek / Preloader.as
Created May 13, 2011 10:05
Flash preloader
package
{
import flash.display.*;
import flash.text.*;
import flash.events.*;
import flash.utils.getDefinitionByName;
[SWF(width = "640", height = "480")]
public class Preloader extends Sprite
{
@Draknek
Draknek / Main.as
Created June 2, 2011 08:12
Font size test
package
{
import net.flashpunk.*;
import net.flashpunk.graphics.*;
import flash.net.*;
import flash.display.*;
[SWF(width = "800", height = "640", backgroundColor="#000000")]
public class Main extends Engine
Annoyances with FlashPunk:
Mask code has nonintuitive data dependencies
-> can directly change origin/size even when mask set
-> hitbox is not a usable mask
Too many private variables: make more stuff public
/** private */ comments: unnecessary and often out of date
Entity.world gets unset immediately when removed
@Draknek
Draknek / Main.as
Created August 12, 2011 23:53
Grid-grid collision bug
package
{
import net.flashpunk.*;
import net.flashpunk.graphics.*;
import net.flashpunk.masks.*;
import flash.display.*;
[SWF(width = "640", height = "480", backgroundColor="#000000")]
public class Main extends Engine
@Draknek
Draknek / stupid_php.php
Created October 31, 2011 17:43
PHP bug
$array['value'] = 'Original';
$reference = &$array['value'];
$array_copy = $array;
$array['value'] = 'Changed';
$array_copy['value'] == 'Changed'; // =(
On init:
var startOrientation:String = FP.stage.orientation;
if (startOrientation == StageOrientation.DEFAULT || startOrientation == StageOrientation.UPSIDE_DOWN)
{
FP.stage.setOrientation(StageOrientation.ROTATED_RIGHT);
}
else
{
@Draknek
Draknek / CopyPaste.as
Created May 14, 2012 22:42
Class for intercepting Ctrl+C and Ctrl+V in AS3
package
{
import flash.display.*;
import flash.events.*;
import flash.text.*;
import flash.ui.*;
public class CopyPaste
{
/**
@Draknek
Draknek / debug-swf.sh
Created June 13, 2012 00:10 — forked from djcsdy/debug-swf.sh
Launches a SWF in a non-interactive fdb session so you can see traces and uncaught exceptions
#!/bin/sh
function getinput {
echo continue
cat
}
SWF="$1"
getinput | fdb "$SWF"