This file contains 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
// ONCE | |
function once(fn, context) { | |
var result; | |
return function() { | |
if(fn) { | |
result = fn.apply(context || this, arguments); | |
fn = null; | |
} |
This file contains 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
var func = function( props ){ | |
props = (typeof props !== "object") ? {} : props; | |
var mx = props.mx || 10; | |
var my = props.my || 10; | |
var mz = props.mz || 10; | |
var time = props.time || 1; | |
var delay = props.delay || 0; | |
var ease = props.ease || Linear.easeNone; |
This file contains 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 RectCircleColliding(circle,rect){ | |
var distX = Math.abs(circle.x - rect.x-rect.w/2); | |
var distY = Math.abs(circle.y - rect.y-rect.h/2); | |
if (distX > (rect.w/2 + circle.r)) { return false; } | |
if (distY > (rect.h/2 + circle.r)) { return false; } | |
if (distX <= (rect.w/2)) { return true; } | |
if (distY <= (rect.h/2)) { return true; } |
This file contains 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
/* | |
val = value to snap | |
inc = increment to snap to | |
example: | |
snapToIncrement(10, 3): 9 | |
snapToIncrement(89, 10): 100 | |
snapToIncrement(35.6, .5): 35.5 | |
*/ |
This file contains 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
// VIDEO; | |
var nc:NetConnection = new NetConnection(); | |
nc.connect(null); | |
var ns:NetStream = new NetStream(nc); | |
ns.client = {}; | |
ns.client.onMetaData = nsOnMetaData; | |
ns.client.onCuePoint = nsOnCuePoint; | |
ns.addEventListener(NetStatusEvent.NET_STATUS, nsOnNetStatus); | |
ns.addEventListener(AsyncErrorEvent.ASYNC_ERROR, onAsyncError); |
This file contains 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 removeAllChildren(mc:MovieClip):void | |
{ | |
while (mc.numChildren) | |
{ | |
mc.removeChildAt(0); | |
} | |
} |
This file contains 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
var vx:Number = 0; | |
var vy:Number = 0; | |
var targetX:Number; | |
var targetY:Number; | |
var spring:Number = .5; | |
var friction:Number = .9; | |
this.addEventListener(Event.ENTER_FRAME, loop); | |
function loop(e:Event):void |
This file contains 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
// FROM http://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame | |
In your main page: | |
var frame = document.getElementById('your-frame-id'); | |
frame.contentWindow.postMessage(/*any variable or object here*/, '*'); | |
In your <iframe> (contained in the main page): | |
window.addEventListener('message', function(event) { |
This file contains 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 scaleAroundPoint(target:DisplayObject, point:Point, scaleFactor:Number):void | |
{ | |
var m:Matrix = target.transform.matrix; | |
m.translate( -point.x, -point.y ); | |
m.scale( scaleFactor, scaleFactor); | |
m.translate( point.x, point.y ); | |
target.transform.matrix = m; | |
} |
This file contains 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 centerTo(_object:DisplayObject, _ref:DisplayObject):void{ | |
if (_object != null){ | |
var _wString:String = "width"; | |
var _hString:String = "height"; | |
if (_ref == stage){ | |
_wString = "stageWidth"; | |
_hString = "stageHeight"; | |
trace("stage"); | |
} | |
var _refWidth:Number = _ref[_wString]; |
NewerOlder