package com {
import flash.display.*;
import flash.net.*;
import flash.events.*;
public class Test extends Sprite {
public var mc:MovieClip = new MovieClip();
public var buttonShape:Shape = new Shape();
public var fileRef:FileReference= new FileReference();
public function Test() {
buttonShape.graphics.beginFill(0x336699);
buttonShape.graphics.drawCircle(50, 50, 25);
var button = new SimpleButton(buttonShape, buttonShape, buttonShape, buttonShape);
addChild(button);
button.addEventListener(MouseEvent.CLICK, onButtonClick);
}
public function onButtonClick(e:MouseEvent):void {
fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png")]);
fileRef.addEventListener(Event.SELECT, onFileSelected);
}
public function onFileSelected(e:Event):void {
fileRef.addEventListener(Event.COMPLETE, onFileLoaded);
fileRef.load();
}
public function onFileLoaded(e:Event):void {
var loader:Loader = new Loader();
loader.loadBytes(e.target.data);
mc.addChild(loader);
addChild(mc);
}
}
}
The code above displays the user selected image. How to get the orginal width and height of the selected image and how set new width and height?