diff --git a/src/starling/textures/TextureAtlas.hx b/src/starling/textures/TextureAtlas.hx index 449d43ef..81c02ca8 100644 --- a/src/starling/textures/TextureAtlas.hx +++ b/src/starling/textures/TextureAtlas.hx @@ -14,10 +14,10 @@ import openfl.geom.Point; import openfl.geom.Rectangle; import openfl.errors.ArgumentError; -import openfl.Vector; import starling.display.Image; import starling.utils.StringUtil; +import starling.utils.ArrayUtil; /** A texture atlas is a collection of many smaller textures in one big image. This class * is used to access textures from such an atlas. @@ -81,10 +81,10 @@ class TextureAtlas @:noCompletion private var __atlasTexture:Texture; @:noCompletion private var __subTextures:Map; - @:noCompletion private var __subTextureNames:Vector; + @:noCompletion private var __subTextureNames:Array; /** helper objects */ - private static var sNames:Vector = new Vector(); + private static var sNames:Array = new Array(); #if commonjs private static function __init__ () { @@ -204,27 +204,31 @@ class TextureAtlas /** Returns all textures that start with a certain string, sorted alphabetically * (especially useful for "MovieClip"). */ - public function getTextures(prefix:String="", result:Vector=null):Vector + public function getTextures(prefix:String="", result:Array=null):Array { - if (result == null) result = new Vector(); + if (result == null) result = new Array(); for (name in getNames(prefix, sNames)) result[result.length] = getTexture(name); // avoid 'push' - sNames.length = 0; + #if (haxe_ver >= 4.0) + sNames.resize(0); + #else + ArrayUtil.resize(sNames, 0); + #end return result; } /** Returns all texture names that start with a certain string, sorted alphabetically. */ - public function getNames(prefix:String="", result:Vector=null):Vector + public function getNames(prefix:String="", result:Array=null):Array { var name:String; - if (result == null) result = new Vector(); + if (result == null) result = new Array(); if (__subTextureNames == null) { // optimization: store sorted list of texture names - __subTextureNames = new Vector(); + __subTextureNames = new Array(); for (name in __subTextures.keys()) __subTextureNames[__subTextureNames.length] = name; __subTextureNames.sort(compare); }