I'm making a small joke flash and I need to know how to resize an external image, keep it's aspect ratio and make it centered in that red box in actionscript. I am able to load the image but that's all I've been able to do. I would love some help with this.
Here is a link to the thing I'm making: http://www.newgrounds.com/dump/item/9aee82f0e7265c197b658f184d415068
Here is the code:
import flash.display.Loader;
import flash.net.FileReference;
import flash.net.FileFilter;
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.ByteArray;
var loader:Loader=new Loader()
mc.addChild(loader)
var fr:FileReference=new FileReference()
fr.addEventListener(Event.SELECT,onselect)
fr.addEventListener(Event.COMPLETE,oncomplete)
BrowseButton.addEventListener(MouseEvent.CLICK,onloade);
function onloade(e:MouseEvent)
{
var filefilter:FileFilter=new FileFilter("Images (*.jpg, *.png)", "*.jpg;*.png");
fr.browse([filefilter])
}
function onselect(e:Event)
{
fr.load()
}
function oncomplete(e:Event)
{
var byteArray:ByteArray=e.currentTarget["data"]
loader.loadBytes(byteArray)
}