In case Flash no longer exists; a copy of this site is included in the Flashpoint archive's "ultimate" collection.

Dead Code Preservation :: Archived AS3 works from wonderfl.net

flash on 2009-12-25

Get Adobe Flash player
by foo9 25 Dec 2009
    Embed
/**
 * Copyright foo9 ( http://wonderfl.net/user/foo9 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/fhg1
 */

package
{
	import flash.text.TextField;
    import flash.display.Sprite;
    import flash.net.FileReference;
    import flash.events.*;
    
    public class FlashTest extends Sprite
    {
    		private var _fr:FileReference;
    		private var _txtfield:TextField;
    	
        public function FlashTest()
        {
        		_txtfield = new TextField();
        		addChild(_txtfield);
        		_txtfield.width = 400;
        		_txtfield.height = 400;
        		_txtfield.addEventListener(MouseEvent.CLICK, onClick);
        		_txtfield.backgroundColor = 0xCCCCCC;
        		_txtfield.background = true;
        		_txtfield.text = "click me";
        	
			_fr = new FileReference();
			_fr.addEventListener(Event.SELECT,onSelect);
        }
	
		private function onClick(e:MouseEvent):void{
    			_fr.browse();
		}
        
		private function onSelect(e:Event):void
		{
  			_fr.addEventListener(ProgressEvent.PROGRESS,onProgress);
  			_fr.addEventListener(Event.COMPLETE,onComplete);
			_fr.load(); // 読み込み開始
		}
 
		private function onProgress(e:ProgressEvent):void
		{
  			_txtfield.text = e.bytesLoaded + " / " + e.bytesTotal;
  		}

		private function onComplete(e:Event):void
		{				
			_txtfield.text += "\n読み込み完了";
			//_fr.data
			//_fr.type
			_fr.removeEventListener(ProgressEvent.PROGRESS,onProgress);
  			_fr.removeEventListener(Event.COMPLETE,onComplete);
		}
    }
}