How many people use ‘URLLoader’ to load resources?
Because I found that ‘URLLoader’ can load ‘images, music, JSON’
Some people may ask why loading “images” is more direct without using “Loader”?
Because I mainly work on “HTML5”, I found that “loader” in HTML5 does not support loading progress, so I used “urlloader”
I have noticed that some people use ‘Loader’ to load multiple ‘images’, but they display the overall progress by calculating the number of files
Is it feasible to display the overall progress by calculating the number of files? Reliable? Is everyone doing the same?
I just woke up and couldn’t wait to post on the forum, hoping to exchange experiences with everyone, even if no one replied to me
I’d like to suggest that what you’re trying accomplish, would provide important context.
I could answer you, “I mostly just use the Assets class the access resources”, but my goals are likely different to yours.
May I ask how you load images, sounds, and JSON using Assets? Is it a type of loading or do you directly load assets.loadLibrary using the library?
In my project.xml, I define paths to my assets (see here for a bit of a rundown):
<assets path="assets/images" rename="images" type="image" />
<assets path="assets/sounds" rename="sounds" type="sound" />
<assets path="assets/json" rename="json" type="text" />
All of these are pointing to a directory, not a specific file. Anything you put in these directories, will now be bundled (but not embedded) with your application.
The rename="blah" part of these nodes allows you to provide a nickname of sorts to reference these assets within code, so you’re not having to reference the full path.
Now in code, you’d access assets from these defined assets like this (see also this reference):
// Grabbing an image.
var bitmapData = Assets.getBitmapData("images/some-image.png");
// Playing a sound.
Assets.getSound("sounds/some-sound.ogg").play();
// Parsing a JSON file (I haven't tested this).
var data:Dynamic = haxe.Json.parse(Assets.getText("json/some-file.json"));
Why not customize the library? Then use Assets.loadLibrary to collectively load resources? Isn’t it more convenient?
This was a basic example to illustrate an answer to your earlier question. There are many ways this could be done, of course.
For example, I’m often using ATF spritesheets. While I define these in my project.xml so they are bundled with my application, I’m using Starling’s AssetManager to pull them in.
I use the assets to load images, sound and text files. The only time I use URLloader is when getting files from an external source. For example if you want to load a video file from a streaming server then URLloader is what you use. I built a streaming video player this way using openFL.
Currently working on a personal passion project and I am using starling and using the starling asset loading which lets you call your asset by name.
