This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package nx.audio { | |
/** | |
*/ | |
public class Oscillator implements ISampleGenerator { | |
private static const WAVEFORM_PULSE:uint = Waveform.PULSE; | |
private static const WAVEFORM_SAWTOOTH:uint = Waveform.SAWTOOTH; | |
private static const WAVEFORM_SINE:uint = Waveform.SINE; | |
private static const WAVEFORM_TRIANGLE:uint = Waveform.TRIANGLE; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.utils.describeType; | |
// | |
// trace( isDefinition(Sprite,"flash.display::Sprite") ); // true | |
// trace( isDefinition(Sprite,"flash.display::InteractiveObject") ); // true | |
// trace( isDefinition(Sprite,"flash.events::EventDispatcher") ); // true | |
// trace( isDefinition(Sprite,"flash.events::Event") ); // false | |
// | |
public function isDefinition( definition:Class, type:String ):Boolean { | |
var info:XML = describeType( definition ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
public class AbstractExample { | |
public function AbstractExample() { | |
if( Object(this).constructor == AbstractExample ) { | |
throw new Error( "AbstractExample class must be extended." ); | |
} | |
} | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Counts the number of bytes in a string. | |
function count_bytes( &$str ) { | |
if( ini_get( 'mbstring.func_overload' ) ) { | |
return mb_strlen( $str, '8bit' ); | |
} | |
// Ideally we want strlen() to be used, because it's fast. | |
return strlen( $str ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function replace( str:String, search:String, replacement:String ):String { | |
var a:int = search.length; | |
var b:int = replacement.length; | |
var o:int = 0; | |
var i:int; | |
while( ( i = str.indexOf( search, o ) ) != -1 ) { | |
str = str.substr( 0, i ) + replacement + str.substr( i + a ); | |
o = i + b; | |
} | |
return str; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const DEGRAD:Number = Math.PI / 180; | |
var iso:Matrix = new Matrix(); | |
iso.rotate( -45 * DEGRAD ); // rotate anti-clockwise by 45 degrees | |
iso.scale( 1.0, 0.5 ); // scale vertically by 50% | |
iso.translate( 100, 100 ); // set position if needed | |
displayObject.transform.matrix = iso; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const CHR:Array = [ | |
"A","B","C","D","E","F","G","H","I","J","K","L","M", | |
"N","O","P","Q","R","S","T","U","V","W","X","Y","Z" | |
]; | |
const CHRLEN:Number = CHR.length; | |
function getRandom():String { | |
return CHR[ CHRLEN * Math.random() >> 0 ]; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class JSONObject extends stdClass { | |
// Accepts an array, object, or JSON encoded string. | |
public function __construct( $o=null ) { | |
if( $o === null ) { | |
return; | |
} | |
if( is_string( $o ) ) { | |
$o = json_decode( $o ); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
new function() { | |
var TRIM = /^\s*(.+?)\s*$/; | |
String.prototype.trim = function() { | |
return this.replace( TRIM, '$1' ); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Works in Chrome, Firefox, MSIE, Opera and Safari. | |
// | |
function onDOMContentLoaded( event ) { | |
if( event ) { | |
document.removeEventListener( event.type, onDOMContentLoaded, false ); | |
} | |
document.onreadystatechange = null; | |
// do something here... | |
} |
OlderNewer