Clearing Loaded ID Array

HomeForumsAssetLoaderGeneral DiscussionClearing Loaded ID Array

Tagged: 

This topic has 2 voices, contains 5 replies, and was last updated by  Matan Uberstein 309 days ago.

Viewing 6 posts - 1 through 6 (of 6 total)
Author Posts
Author Posts
July 14, 2011 at 9:48 am #724 Quote

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>
July 14, 2011 at 9:57 am #815

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. :)

July 14, 2011 at 10:02 am #816

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

July 14, 2011 at 10:14 am #817

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 ;)

July 14, 2011 at 11:24 am #818

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

July 14, 2011 at 11:31 am #819

Matan Uberstein

Perfect! Thanks for posting! Another way would be:

1

Viewing 6 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic.