Skip to content

Instantly share code, notes, and snippets.

View mattlundstrom's full-sized avatar

Matt Lundstrom mattlundstrom

View GitHub Profile
@mattlundstrom
mattlundstrom / gist:2938102
Created June 15, 2012 18:43
Flash Text Descrambler
var randomChars:String = "A_B_C_D_E_F_G_H_I_J_K_L_M_N_O_P_!_@_#_$_%_^_&_!_ _ _ _ _ _ _"
var charArray:Array = randomChars.split("_");
function descramble(speed:int, txt:TextField):void{
var originalString:String = txt.text;
var newFragment:String;
var newString:String;
var characterNum:int = 0;
@mattlundstrom
mattlundstrom / gist:2938136
Created June 15, 2012 18:48
Flash Proportional Resize To Fit
function proportionalResizeToFit(resizingMC:Object, referenceMC:Object, useHeight:Boolean){
var origWidth:Number = resizingMC.width;
var origHeight:Number = resizingMC.height;
var ratio:Number = origHeight / origWidth;
if (useHeight){
resizingMC.height = referenceMC.height;
resizingMC.width = resizingMC.height / ratio;
} else {
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);
@mattlundstrom
mattlundstrom / gist:2938211
Created June 15, 2012 19:04
Flash get browser name
function getBrowserName():String
{
var browser:String;
//Uses external interface to reach out to browser and grab browser useragent info.
var browserAgent:String = ExternalInterface.call("function getBrowser(){return navigator.userAgent;}");
//Determines brand of browser using a find index. If not found indexOf returns (-1).
if(browserAgent != null && browserAgent.indexOf("Firefox")>= 0) {
browser = "Firefox";
}
else if(browserAgent != null && browserAgent.indexOf("Safari")>= 0){
@mattlundstrom
mattlundstrom / gist:2938219
Created June 15, 2012 19:06
Flash Programmatic Easing
import flash.events.Event;
this.addEventListener(Event.ENTER_FRAME, loop);
var drag:Number = 10;
var mc:MovieClip = new MovieClip;
var gfx:Graphics = mc.graphics;
gfx.beginFill(0x000000);
gfx.drawCircle(0,0,10);
addChild(mc);
@mattlundstrom
mattlundstrom / gist:2938310
Created June 15, 2012 19:25
Flash Bezier Curve
var bmd:BitmapData = new BitmapData(800,600,false, 0x000000);
addChild(new Bitmap(bmd));
bmd.fillRect(bmd.rect, 0x000000);
for (var i:Number = 0; i<=1; i+= 0.01) {
var xp:Number = b(i, 100, 300, 500);
var yp:Number = b(i, 300, 100, 300);
bmd.setPixel(xp, yp, 0xFFFFFF);
}
@mattlundstrom
mattlundstrom / gist:2938314
Created June 15, 2012 19:27
Flash Interpoint
function calulateInterpoint(p1:Point,p2:Point,percent:Number ):Point
{
var temporaryPoint:Point = new Point;
temporaryPoint.x = p1.x + ( p2.x - p1.x ) / (100/percent)
temporaryPoint.y = p1.y + ( p2.y - p1.y ) / (100/percent)
return temporaryPoint;
}
@mattlundstrom
mattlundstrom / gist:2939082
Created June 15, 2012 22:46
PHP Mobile Sniffer
<?php
$browser = getenv(“HTTP_USER_AGENT”);
echo '<p>HTTP User Agent is: ' . $browser . '</p>';
if (eregi(‘iPhone’, $browser))
{
echo 'You are using an iPhone';
}
else if (eregi(‘Blackberry’, $browser))
{
@mattlundstrom
mattlundstrom / gist:2939083
Created June 15, 2012 22:47
PHP Mobile Redirect
<html>
<head>
<script type="text/javascript">
function redirect(url)
{
window.location.href = url;
}
</script>
</script>
</head>
@mattlundstrom
mattlundstrom / gist:2939090
Created June 15, 2012 22:48
CSS Remove Firefox Dotted Borders
a:focus {
outline: none;
}