Search This Blog

Sunday, September 4, 2011

Here is an example that loads in a file and traces its contents:---- from JTD FLASh from gotoAndLearn()

var btn:Sprite = new Sprite();
btn.graphics.beginFill(0);
btn.graphics.drawRect(0,0,100,20);
btn.graphics.endFill();
addChild(btn);

var fr:FileReference = new FileReference();
fr.addEventListener(Event.COMPLETE, completeHandler);
fr.addEventListener(Event.SELECT, selectHandler);

btn.addEventListener(MouseEvent.CLICK, onBtnClicked);

function onBtnClicked(ev:MouseEvent):void {
   fr.browse(); //Use arguments to restrict file types. See Lang Ref.
}

function completeHandler(ev:Event):void {
   trace(fr.data);
}

function selectHandler(ev:Event):void {
   fr.load();
}

No comments:

Post a Comment