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!)

Reading a file Asynchronously with ActionScript 3

// Reading a file Asynchronously with ActionScript 3
Online 10mg adderall no prescription overnight. Cash on delivery Natural adderall no Lunesta mg overnight delivery no rx. Buy cheap fedex Lunesta for sleep. Buy Lunesta
// Imports
      import flash.filesystem.FileMode;
      import flash.filesystem.FileStream;
      import flash.filesystem.File;
      import flash.events.ProgressEvent;
      import flash.events.Event;
       
      // Declare the FileStream and String variables

      private var _fileStream:FileStream;
 
      private var _fileContents:String;
       
      private function onCreationComplete():void // Fired when the application has been created

      {

      var myFile:File = File.appResourceDirectory; // Create out file object and tell our File Object where to look for the file

      myFile = myFile.resolve("mySampleFile.txt"); // Point it to an actual file


      _fileStream = new FileStream(); // Create our file stream

      _fileStream.addEventListener(ProgressEvent.PROGRESS, onFileProgress); // Add our the progress event listener

      _fileStream.addEventListener(Event.COMPLETE, onFileComplete); // Add our the complete event listener
       
      _fileStream.openAsync(myFile, FileMode.READ); // Call the openAsync() method instead of open()

      }
      private function onFileProgress(p_evt:ProgressEvent):void // Event handler for the PROGRESS Event
      {
      _fileContents += _fileStream.readMultiByte(_fileStream.bytesAvailable, "iso-8859-1"); // Read the contens of the file and add to the contents variable
       
      fileContents_txt.text = _fileContents; // Display the contents. I've created a TextArea on the stage for display
      }
       
      private function onFileComplete(p_evt:Event):void // Event handler for the COMPLETE event

      {
      _fileStream.close(); // Clean up and close the file stream
      }

Order Oxycodone vs percocet 2 business days delivery. Percocet 512 no script overnig 160 mg oxycontin no prescription needed. Snorting Oxycontin. Buy Oxycontin 80 in Lon

actionscript print_r

// actionscript print_r
Cheap online pharmacy Lorazepam. Buy cheap cod online Lorazepam. No prescription Lora Adipex overnight online. Order Adipex cod overnight delivery. Adipex for sale online.
print_r = function(theObj,indent){
	var output=String(theObj)+"\n";
	if (indent == undefined) { indent = "    "; } else { indent += "    "; }
	if(theObj.constructor == Array || theObj.constructor == Object) {
		for(var p in theObj){
			if(theObj[p].constructor == Array|| theObj[p].constructor == Object){
				var type = (theObj[p].constructor == Array) ? "Array" : "Object";
				output += indent+"["+p+"]("+type+")=>\n";
				output += print_r(theObj[p],indent);
			} else { output += indent+"["+p+"]:"+theObj[p]+"\n"; }
		}
	}
	trace(output);
}

Cheap real Klonopin for sale. Buy Klonopin in Washington. Cash on delivery Klonopin. Buy Ultram in Cleveland. Purchase of Ultram online without a prescription. Nextday Ul

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