I’m want to use a URLLoader in one line, but I know Internet Explorer has given me problems loading local files when the listener is added after the load call.
new URLLoader(new URLRequest('http://example.com')).addEventListener(
Event.COMPLETE, handleLoadedData
);
I know the verbose, but safe way of using a URLLoader is:
var request:URLRequest = new URLRequest('http://example.com');
var loader:URLLoader = new URLLoader();
loader.addEventListener(Event.COMPLETE, handleLoadedData);
loader.load(request);
What’s the most concise way of using URLLoader that works with local files?
What about creating a class that offers a simple way to load data and just reuse it?
I mean something simple like this:
And then, you’d use it in one line like this:
I’ve proposed a similar idea here. It’s basically the same idea, just adding some basic error handling.