gets and posts from a php
// ------------------------------
/*
GETS THE REQUESTED URL
-- perfect for when you need to do
a lot of retrieving from a PHP
*/
// ------------------------------
package com.drpunchlogic
{
// imports
import flash.net.URLLoader;
import flash.net.URLRequest;
import flash.xml.XMLDocument;
// --
import flash.events.*;
import flash.errors.*;
public class GetUrl
{
public function GetUrl( www:String ) : void
{
// send an updated request
var loader:URLLoader = new URLLoader();
sentListeners(loader);
var url:URLRequest = new URLRequest( www );
try {
loader.load( url );
} catch (error:Error) {
trace("{ ERROR: can't send update: " + www + " }" );
}
}
private function sentListeners( dispatcher:IEventDispatcher ) : void
{
dispatcher.addEventListener( Event.COMPLETE, completeHandler );
dispatcher.addEventListener( Event.OPEN, openHandler );
dispatcher.addEventListener( ProgressEvent.PROGRESS, progressHandler );
dispatcher.addEventListener( SecurityErrorEvent.SECURITY_ERROR, securityErrorHandler );
dispatcher.addEventListener( HTTPStatusEvent.HTTP_STATUS, httpStatusHandler );
dispatcher.addEventListener( IOErrorEvent.IO_ERROR, ioErrorHandler );
}
private function completeHandler( e:Event ) : void
{
var loader:URLLoader = URLLoader( e.target );
trace( "{ completeHandler: " + loader.data + " }" );
}
private function openHandler( e:Event ) : void
{
trace( "{ openHandler: " + e + " }" );
}
private function progressHandler( e:ProgressEvent ) : void
{
trace( "{ progressHandler loaded:" + e.bytesLoaded + " total: " + e.bytesTotal + " }" );
}
private function securityErrorHandler( e:SecurityErrorEvent ) : void
{
trace( "{ securityErrorHandler: " + e + " }" );
}
private function httpStatusHandler( e:HTTPStatusEvent ) : void
{
trace( "{ httpStatusHandler: " + e + " }" );
}
private function ioErrorHandler( e:IOErrorEvent ) : void
{
trace( "{ ioErrorHandler: " + e + " }" );
}
}
}

Post a Comment