 newtriks
|
<p>Hey man,</p>
<p>Quick question on the best way to clear the loaded id array (its a getter). Currently prior to loading specific images from an array of url’s I am using your hasLoader() method for example:</p>
<p>if(!assetLoader.hasLoader(_index.toString()))</p>
<p>I want to reset those id’s when I create a new array of image url’s. Whats the best way to do this, obviously loadedIds is a getter so I cannot target that directly.</p>
<p>Cheers,</p>
<p>Simon
</p>
|
 Matan Uberstein
|
Ok, so you have an IAssetLoader that contains images. Then at some point after some loading has occurred you’d like to clear out the current loaders and replace them with new ones?
- If so, iterate through the “loadedIds” getter and use the “remove” method to remove the loaders from the queue.
I assume you want to do this in this manner to retain the instance of IAssetLoader and not destroy it. I can see this is useful if you have listeners attached etc.
Let me know how it turns out.
|
 newtriks
|
Excellent thanks!
This was the route I had taken tbh, I was just checking to see if there may have been an existing method on AssetLoader to handle this already, save re-inventing the wheel if you know what I mean.
Cheers man,
Simon
|
 Matan Uberstein
|
Great!
I thought about this a while ago, but there hasn’t been a demand for it, also I don’t want to bloat AssetLoader too much. This type of functionality is easy to write and somehow feels rewarding for person doing it – in my opinion.
There are so many “shortcuts” one could add into AssetLoader e.g.
assetloader.removeAll();
assetloader.removeAllLoaded();
assetloader.removeAllFailed();
assetloader.restartAllFailed();
loader.autoRemoveAfterComplete = true;
loader.turnIntoARobotAfterError = true;
etc.
Hehe You get what I’m saying
|
 newtriks
|
LOl, yeh agreed, Just a heads up to anyone who does actually do this then due to the nature of remove() splicing and deleting indexes in the array, logic to remove the id in a loop would be as follows:
1
|
 Matan Uberstein
|
Perfect! Thanks for posting! Another way would be:
1
|