         var area :int = 0;
         var maxW :int = 0;
         var maxH :int = 0;
+
         for each (var tex :SwfTexture in _unpacked) {
             var w :int = tex.w + 2*Atlas.PADDING;
             var h :int = tex.h + 2*Atlas.PADDING;

            }
        }
        _unpacked.sort(Comparators.createReverse(Comparators.createFields(["a", "w", "h"])));
        while (_unpacked.length > 0) pack();
    }

    public function get targetDevice () :DeviceType {

    }

    protected function pack () :void {

        while (_unpacked.length > 0) {
            // Add a new atlas
            var size :Point = findOptimalSize();
            atlases.push(new Atlas(_lib.location + "/atlas" + atlases.length,
                _target, size.x, size.y));

            // Try to pack each texture into any atlas
            for (var ii :int = 0; ii < _unpacked.length; ++ii) {
                var tex :SwfTexture = _unpacked[ii];

                if (tex.w > MAX_SIZE || tex.h > MAX_SIZE) {
                    throw new Error("Too large to fit in an atlas");
                }

                for each (var atlas :Atlas in atlases) {
                    // TODO(bruno): Support rotated textures?
                    if (atlas.place(tex)) {
                        _unpacked.splice(ii--, 1);
                        break;
                    }
                }
            }
        }
    }

    // Estimate the optimal size for the next atlas
