diff --git a/flixel/graphics/frames/FlxAtlasFrames.hx b/flixel/graphics/frames/FlxAtlasFrames.hx index b1f3245c74..83d81b7d63 100644 --- a/flixel/graphics/frames/FlxAtlasFrames.hx +++ b/flixel/graphics/frames/FlxAtlasFrames.hx @@ -244,13 +244,20 @@ class FlxAtlasFrames extends FlxFramesCollection var frames:FlxAtlasFrames = FlxAtlasFrames.findFrame(graphic); if (frames != null) return frames; - - if (graphic == null || xml == null) + + final xmlData = xml.getFirstElement(); + if (xmlData == null) + { + FlxG.log.warn('Invalid xml: $xml'); return null; - + } + + if (graphic == null) + return null; + frames = new FlxAtlasFrames(graphic); - - var data:Access = new Access(xml.getXml().firstElement()); + + var data:Access = new Access(xmlData); for (texture in data.nodes.SubTexture) { @@ -323,15 +330,20 @@ class FlxAtlasFrames extends FlxFramesCollection var frames = FlxAtlasFrames.findFrame(graphic); if (frames != null) return frames; - - if (graphic == null || xml == null) + + final xmlData = xml.getFirstElement(); + if (xmlData == null) + { + FlxG.log.warn('Invalid xml: $xml'); return null; - + } + + if (graphic == null) + return null; + frames = new FlxAtlasFrames(graphic); - - final data = xml.getXml(); - - for (sprite in data.firstElement().elements()) + + for (sprite in xmlData.elements()) { var trimmed = (sprite.exists("oX") || sprite.exists("oY")); var rotated = (sprite.exists("r") && sprite.get("r") == "y"); diff --git a/flixel/system/FlxAssets.hx b/flixel/system/FlxAssets.hx index 503dee6459..4ea19e70fe 100644 --- a/flixel/system/FlxAssets.hx +++ b/flixel/system/FlxAssets.hx @@ -75,6 +75,11 @@ abstract FlxXmlAsset(OneOfTwo) from Xml from String return cast(this, Xml); } + inline public function getFirstElement() + { + return getXml().getFirstElement(); + } + static inline function fromPath(path:String):Xml { return fromXmlString(Assets.getText(path));