lucaslorentz / AS3SVGRenderer

An AS3 SVG Renderer for Flash Player.
106 stars 27 forks source link

Invalid position of image when using href within tag versus embedded image. #50

Closed MitchellAJ closed 9 years ago

MitchellAJ commented 9 years ago

When I define an image tag and use ( xlink:href="myimage.png" ) as an attribute, the resulting image is not positioned correctly according to the x and y specified in the tag.

I briefly reviewed the code (SVGImage.as) and added the x and y positioning as follows:

   public function loadURL(url:String):void
    {
        if (_loader != null)
        {
            content.removeChild(_loader);
            _loader = null;
        }

        if (url != null)
        {
            _loader = new Loader();
            _loader.x = int(svgX); // ADDED
            _loader.y = int(svgY); // ADDED
            _loader.contentLoaderInfo.addEventListener(Event.COMPLETE, loadComplete);
            _loader.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR,
                                                       loadError);
            _loader.load(new URLRequest(url));
            content.addChild(_loader);
        }
    }

This does appear to correct the issue, but is it the right solution?

MitchellAJ commented 9 years ago

After looking at more code, I'm sure it is not the right spot, but where is the issue?

MitchellAJ commented 9 years ago

My problem:

added preserveAspectRatio="none" to the image tag and it positions correctly.