Skip to main content
dareDimantor
Participant
August 23, 2015
Question

How could i have the user upload an image to a flash file?

  • August 23, 2015
  • 1 reply
  • 253 views

eg. User uploads image file and it changes a photo to that image

This topic has been closed for replies.

1 reply

kglad
Community Expert
Community Expert
August 23, 2015

you can use the filereference class to load a user file into flash:

var fileRef:FileReference= new FileReference(); 
button.addEventListener(MouseEvent.CLICK, onButtonClick);  
function onButtonClick(e:MouseEvent):void { 
fileRef.browse([new FileFilter("Images", "*.jpg;*.gif;*.png")]); 
fileRef.addEventListener(Event.SELECT, onFileSelected); 
function onFileSelected(e:Event):void {
 fileRef.addEventListener(Event.COMPLETE, onFileLoaded); fileRef.load(); 
function onFileLoaded(e:Event):void { 
var loader:Loader = new Loader(); loader.loadBytes(e.target.data); 
addChild(loader); 
}