Monday, 12 July 2010

Sending/Loading... Something

I have to look this up every single time, so I thought I would put it somewhere easy to find:

function submitData() {

var nRequest:URLRequest = new URLRequest('backend.php');
nRequest.method = URLRequestMethod.POST;
var dataObj:URLVariables = new URLVariables();
dataObj.someInfo = 'some information';
nRequest.data = dataObj;
var loader:URLLoader = new URLLoader(nRequest);
loader.dataFormat = URLLoaderDataFormat.VARIABLES;
loader.addEventListener(Event.COMPLETE, onComplete);
loader.load(nRequest);

}

function onComplete(evnt:Event) {

var rVariables:URLVariables = new URLVariables(evnt.target.data);
trace(rVariables.someReturnedValue);

}

So in summary,

URLLoader --> URLRequest --> URLVariables

Friday, 2 July 2010

Events and Priorities

Just a note for future reference:

I tried using the priority parameter of a MouseEvent listener, to make the listener on the root get called before the listener within the movie clip, but it wouldn't work.

It was, however, able to distinguish between two listeners on the root timeline...