Skip to content

Instantly share code, notes, and snippets.

View robertpenner's full-sized avatar

Robert Penner robertpenner

View GitHub Profile
@robertpenner
robertpenner / setIntervalInternals.as
Created November 26, 2009 18:58
setInterval internals decompiled from Flash 10 playerglobal.swc
//Created by Action Script Viewer - http://www.buraks.com/asv
package flash.utils {
public function setTimeout(closure:Function, delay:Number, ... _args):uint{
return (new SetIntervalTimer(closure, delay, false, _args).id);
}
}//package flash.utils
import flash.events.*;
@robertpenner
robertpenner / EnterFrameDispatcher.as
Created November 26, 2009 19:49
EnterFrameDispatcher using timeline to avoid Event creation
package
{
import flash.display.MovieClip;
import org.osflash.signals.Signal;
/**
* This class needs to be associated with a movie clip symbol containing two blank frames on its timeline.
* Usage:
*
* var dispatcher:EnterFrameDispatcher = new EnterFrameDispatcher();
@robertpenner
robertpenner / SignalsHelloWorld.as
Created December 3, 2009 05:42
A simple example of using Signals to dispatch changes to a property.
package
{
import org.osflash.signals.Signal;
import flash.display.Sprite;
public class SignalsHelloWorld extends Sprite
{
private var radio:Radio;
private var messageListener:MessageListener;
@robertpenner
robertpenner / SignalAsMXMLTag.mxml
Created February 11, 2010 02:51
Signal as MXML tag in Flex 4
<?xml version="1.0"?>
<!--
~ RegFormRLSExample - RegView.mxml
~
~ Copyright (c) 2010. Newtriks Ltd <simon@newtriks.com>
~ Your reuse is governed by the Creative Commons Attribution 3.0 License
-->
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/halo"
@robertpenner
robertpenner / URLLoader.as
Created March 9, 2010 18:32
flash.net.URLLoader class decompiled from Flash 10 playerglobal.swc
//Created by Action Script Viewer - http://www.buraks.com/asv
package flash.net {
import flash.events.*;
import flash.utils.*;
public class URLLoader extends EventDispatcher {
private var stream:URLStream;
public var dataFormat:String;// = "text"
public var data;
@robertpenner
robertpenner / VectorClassesFP10
Created April 13, 2010 20:42
Vector classes decompiled from Flash 10 playerglobal.swc
package {
dynamic final class Vector$object {
function Vector$object(length:uint=0, fixed:Boolean=false){
super();
this.length = length;
this.fixed = fixed;
}
private function _shift(){
if (this.fixed){
@robertpenner
robertpenner / applyClassToInstance.as
Created April 29, 2010 18:19
Inheritance chain hacking in AS2
/**
* Makes an object inherit from a class.
* Modifies the inheritance chain and calls the class constructor.
* Commonly used to make a movie clip such as the root timeline
* inherit from a custom class, e.g.
* // on main timeline
* applyClassToInstance(MyDocumentClass, this);
* Works for AVM1 only, i.e. AS1 and AS2.
* @param theClass
* @param theInstance
@robertpenner
robertpenner / signal-cake.as
Created June 4, 2011 15:44 — forked from alecmce/signal-cake.as
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);
@robertpenner
robertpenner / All the Singletons.txt
Created October 20, 2011 04:17
All the Singletons
All the Singletons, all the Singletons
All the Singletons, all the Singletons
All the Singletons, all the Singletons
All the Singletons, all the Singletons
If you liked it then you shoulda put an instance on it
If you liked it then you shoulda made it global static
Don't be mad once you see you can't unit test it
If you liked it then you shoulda made a Singleton
@robertpenner
robertpenner / gist:1319052
Created October 27, 2011 08:24
trying to get function signature
protected function listenerValid(listener:Function):Boolean
{
var scope:Array = getLexicalScopes(listener);
var scopeXML:XML = flash.utils.describeType(scope[0]);
// No clue on how to get the "name" of the function passed. I had to use a hard coded string of "hearSignal" for this test
var functionDescriptionXML:XML = scopeXML.factory.method.(@name == "hearSignal")[0];
var params:XMLList = functionDescriptionXML..parameter;
}