Jump to content
Search Community

border around loaded image does not fit

algro test
Moderator Tag

Recommended Posts

I would like to draw a border around an loaded image which has been scaled with scalemode:"proportionalOutside"

… 
private function onImageLoaded(e:LoaderEvent):void
{
var imgLoader:ImageLoader = e.target as ImageLoader;
var img:Sprite = imgLoader.content;
addChild(img);
img.graphics.lineStyle(5,0x000000);
img.graphics.drawRect(0,0,???,???);
}

 

I tried imgLoader.content.width and imgLoader.rawContent.width and img.width

the border never fits to the actual visible imageSize.

 

Thanks for help

Link to comment
Share on other sites

I don't know if this is the best way, but it worked for proportionalInside and proportionalOutside

 

var imgLoader:ImageLoader = e.target as ImageLoader;
var img:Sprite = imgLoader.content;
var rawImg = imgLoader.rawContent;

addChild(img);


img.graphics.lineStyle(5,0x000000);
img.graphics.drawRect(rawImg.x,rawImg.y,rawImg.width,rawImg.height);

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...