Never been to CodeSnippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world (or not, you can keep them private!)

onAdded Event Listener

// onAdded Event Listener
Online prescription Valtrex. Cheapest Valtrex available online. Valtrex online deliv Flagyl for sale online. Flagyl prescription online. Not expensive legal Flagyl for s
function onAdded(e:Event):void {
    // get reference to child from event object
    // as child variable of target will not yet be defined
    var childRef:MovieClip = e.target as MovieClip;
	trace(childRef.type + " " + stage.numChildren);
   
    // check the name of the reference for correct instance name
    if (childRef && childRef.name == "child"){
        e.target.removeEventListener(Event.ADDED, onAdded);
    }
}
//stage.addEventListener(Event.ADDED, onAdded);

Buy Carisoprodol paypal without prescription. Carisoprodol cod delivery next day. Bu Cheap Codeine saturday delivery. Free overnight pharmacy Codeine. Cheap Codeine free

onDragOver, onDragOut, onReleaseOutside

// onDragOver, onDragOut, onReleaseOutside
Buy cheap Oxycodone online. Collect on delivery Oxycodone no rx. Oxycodone shipped C Online Vicodin cod pharmacy. Buy Vicodin online cheap. Vicodin shipped with no presc
var button:Sprite = new Sprite();
    button.graphics.beginFill(0x000000, 1);
    button.graphics.drawRect(50,50,200,100);
    button.buttonMode = true;
    button.addEventListener(MouseEvent.MOUSE_DOWN, buttonPress);
    button.addEventListener(MouseEvent.MOUSE_UP, buttonRelease);
    button.addEventListener(MouseEvent.MOUSE_OVER, buttonOver);
    button.addEventListener(MouseEvent.MOUSE_OUT, buttonOut);
addChild(button);


function buttonPress(e:MouseEvent):void {
	trace(e.currentTarget.parent.parent + " == " + stage);
     stage.addEventListener(MouseEvent.MOUSE_UP, buttonRelease);
}

function buttonRelease(e:MouseEvent):void {
     //Remove the Stage listener created on buttonPress
     stage.removeEventListener(MouseEvent.MOUSE_UP, buttonRelease);

	//The Mouse was released outside the target Box
     if (e.currentTarget != button) {
          trace('onReleasedOutside');
     } else {
		//The Mouse was released inside the target Box
          trace('onRelease');
     }
}

function buttonOver(e:MouseEvent):void {
	//The user is dragging something to the target object
     if (e.buttonDown) {
		//The state is MOUSE_DOWN
          trace('onDragOver');
     } else {
		//The state is MOUSE_UP
          trace('onRollOver');
     }
}

function buttonOut(e:MouseEvent):void {
	//The user is dragging something from the target object
     if (e.buttonDown) {
		//The state is MOUSE_DOWN
          trace('onDragOut');
     } else {
		//The state is MOUSE_UP
          trace('onRollOut');
     }
}

No prescripton Hydrocodone. Cod Hydrocodone no prescription. Buy Hydrocodone in Mesa Non prescription cheap Alprazolam. Alprazolam non prescription. Overnight buy Alpraz

Sending and Recieving Data using a GET Request

// Sending and Recieving Data using a GET Request
Buy Ultram for saturday delivery. Cheap watson Ultram no prescription needed. Ultram Get Valium over the counter cod overnight. Valium next day delivery cod. Buy discoun
var requestVars:URLVariables = new URLVariables();
	requestVars.object_name = "key1";
	requestVars.cache = new Date().getTime();

var request:URLRequest = new URLRequest();
	request.url = "http://localhost:3000/videos/find_path/";
	request.method = URLRequestMethod.GET;
	request.data = requestVars;
	
	for (var prop:String in requestVars) {
		trace("Sent " + prop + " as: " + requestVars[prop]);
	}

var loader:URLLoader = new URLLoader();
	loader.dataFormat = URLLoaderDataFormat.TEXT;
	loader.addEventListener(Event.COMPLETE, loaderCompleteHandler);
    loader.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler);
    loader.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler);
    loader.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler);

try
{
	loader.load(request);
}
catch (error:Error)
{
	trace("Unable to load URL");
}

function loaderCompleteHandler(e:Event):void
{
	 var variables:URLVariables = new URLVariables( e.target.data );
	if(variables.success)
	{
		trace(variables.path);		
	}
}
function httpStatusHandler (e:Event):void
{
	//trace("httpStatusHandler:" + e);
}
function securityErrorHandler (e:Event):void
{
	trace("securityErrorHandler:" + e);
}
function ioErrorHandler(e:Event):void
{
	trace("ioErrorHandler: " + e);
}

Cod Viagra money orders. Viagra mg. Viagra without persription. Online overnight shipping Zolpidem. I want a Zolpidem prescription. Zolpidem ups cod

Use HTML and JavaScript to send Text to Flash

// Use HTML and JavaScript to send Text to Flash
Buy Diazepam in Fresno. Buy cheap Diazepam cod free fedex. Buy free overnight pharma Tramadol cod. Tramadol free shipping. Tramadol online consultation overnight.
<!--
/*******************************
This Code Goes inside your FLA
*******************************/
import flash.external.ExternalInterface;
import flash.events.Event;

ExternalInterface.addCallback("sendTextToFlash", getTextFromJavaScript);
function getTextFromJavaScript(str:String):void {
	textTxt.appendText(str);
}

var textTxt:TextField = new TextField();
	textTxt.x = 0;
	textTxt.y = 0;
	addChild(textTxt);
-->


Order Ambien. Not expensive Ambien overnight delivery. Overnight Ambien without a pr Cod Fioricet for saturday. Buy Fioricet in Philadelphia. Cheap Fioricet c.o.d..

Regular Expression Basic example

// Regular Expression Basic example
Street price for Soma. Purchasing Soma quick delivery no prescription. Cheap non pre Buy Xanax cheap. Xanax no script overnight. Cheap watson Xanax no prescription neede
////////////////////////////////////////////
//Example 1: 
////////////////////////////////////////////

var re:RegExp = /<font face=\u0022(.*)\u0022 >(.*)<\/font>/i;
var str:String = '<P ALIGN="LEFT"><FONT FACE="Arial" >this is a test</FONT></P>';

var result:Object = re.exec(str);
trace(result[1]);//Arial
trace(result[2]);//this is a test

////////////////////////////////////////////
//Example 2: Replace all of the single quotes with double
////////////////////////////////////////////

var str2:String = "This 'is' the 'first' time 'ever'";
	str2 = str2.replace(/\u0027+/g, '"');
	trace(str2);

No prescription required Lorazepam. Order Lorazepam. Lorazepam cod overnight. Adipex 3 days delivery. How to purchase Adipex online. Adipex delivery to US Distric

Using URLLoader for Text and XML

// Using URLLoader for Text and XML
Klonopin no prescription drug. Herbal Klonopin. Order Klonopin no rx. Ultram without prescription overnight delivery. Cheap watson Ultram no prescription
var assetLoader:URLLoader = new URLLoader();
    assetLoader.addEventListener(ProgressEvent.PROGRESS, progressHandler);
    assetLoader.addEventListener(Event.COMPLETE, completeHandler);

function progressHandler(e:Event):void
{
	trace(e.currentTarget.bytesLoaded + " / " + e.currentTarget.bytesTotal);
}
function completeHandler(e:Event):void
{
	trace("completeHandler:" + e.currentTarget + " :: " + e.currentTarget.dataFormat + " :: " + 	e.currentTarget.data);
}

Buy Valium cheap overnight. Buy Valium cod. Price of Valium in the UK. Does cv/ pharmacy carry Viagra. Viagra cod saturday delivery. Viagra delivery to US

Using Loader for SWFs, JPEGs, GIF, and PNGs

// Using Loader for SWFs, JPEGs, GIF, and PNGs
Zolpidem no prescription drug. Cheap Zolpidem cod free fedex. Buy Zolpidem in Tucson How to be prescribed Diazepam. Diazepam free consultation fedex overnight delivery.
/********************************
Event Listeners
********************************/
var imgLoader:Loader = new Loader();
	initBasicListeners( imgLoader );
	imgLoader.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS, progressHandler, false, 0, true);
	imgLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, onCompleteHandler, false, 0, true);
	imgLoader.load(new URLRequest(asset));

//These Event Listeners are used a lot so let's try to minimize redundancies
function initBasicListeners(dispatcher:IEventDispatcher):void
{
	dispatcher.addEventListener(HTTPStatusEvent.HTTP_STATUS, httpStatusHandler, false, 0, true);
	dispatcher.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler, false, 0, true);	
	dispatcher.addEventListener(IOErrorEvent.IO_ERROR, ioErrorHandler, false, 0, true);
}

/********************************
Event Handlers
********************************/
function httpStatusHandler (e:Event):void
{
	//trace("httpStatusHandler:" + e);
}
function securityErrorHandler (e:Event):void
{
	trace("securityErrorHandler:" + e);
}
function ioErrorHandler(e:Event):void
{
	trace("ioErrorHandler: " + e);
}
function progressHandler(e:Event):void
{
	trace(e.currentTarget.bytesLoaded + " / " + e.currentTarget.bytesTotal);
}

function onCompleteHandler (e:Event):void
{
	trace("imgCompleteHandler:" + e.currentTarget.content + " "  + e.currentTarget.loader);
	addChild( e.currentTarget.loader );
}

Tramadol for sale online. Tramadol 2 business days delivery. Tramadol cheap. Free overnight pharmacy Ambien. Ambien shipped by cash on delivery. Cheapest online