away3d/away3d-core-fp11 — Issue #195: AssetLibrary removeNamespaceAssets bug
Author: yesbaba
Created: 2011-12-13 08:25:47+00:00
State: open

_assets is cleared but still used in the loop,
old_assets should be used in for loop

public function removeNamespaceAssets(ns : String=null, dispose : Boolean = true) : void
{
var idx : uint = 0;
var asset : IAsset;
var old_assets : Vector.;

// Empty the assets vector after having stored a copy of it.
// The copy will be filled with all assets which weren’t removed.
old_assets = _assets.concat();
_assets.length = 0;

ns ||= NamedAssetBase.DEFAULT_NAMESPACE;
for each (asset in _assets) {
// Remove from dict if in the supplied namespace. If not,
// transfer over to the new vector.
if (asset.assetNamespace == ns) {
if (dispose)
asset.disposeAsset();
removeAssetFromDict(asset);
}
else {
_assets[idx++] = asset;
}
}
}