I have a problem that when I load image it doesn't resize to the value I set in my button, so the button resize itself to fill the image, i think!
And when I see value like 200,200 the resulted image is like 3-4 times bigger than 100,100
public function MyButton()
{// this is ctor
ImageLoader = new Loader();
addChild(ImageContainer);
}
public function SetWidthAndHeight(newWidth: Number, newHeight: Number): void
{
width = newWidth;
height = newHeight;
//ImageContainer is a MovieClip inside the button
ImageContainer.height = newHeight;
ImageContainer.width = newWidth;
}
public function LoadImage(address: String): void
{
ImageLoader.load(new URLRequest(address));
}
I set the value like
var g_newButton = new MyButton();
g_newButton.ImageLoader.contentLoaderInfo.addEventListener(Event.COMPLETE, OnCompleteHandler);**strong text**
g_newButton.SetWidthAndHeight(100,100);
g_newButton.LoadImage("myImage.jpg");
function OnCompleteHandler(loadEvent: Event)
{
//g_newButton.ImageLoader.content is always null
trace("button width " +g_newButton.width);
trace("button height " +g_newButton.height);
g_newButton.ImageContainer.addChild(loadEvent.currentTarget.content);
addChild(g_newButton);
}
when I run, these are the values I get
button width 750
button height 385.55
so Why i am not getting
button width 100
button height 100 what should i do to make the image resize to fill a button or to have the same size of the button