copying and pasting

by wh0 forked from flash on 2010-5-16 (diff: 25)
now with source code
♥0 | Line 31 | Modified 2011-02-20 06:16:09 | MIT License
play

ActionScript3 source code

/**
 * Copyright wh0 ( http://wonderfl.net/user/wh0 )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/yR43
 */

// forked from wh0's flash on 2010-5-16
package {
    import flash.desktop.*;
    import flash.display.*;
    import flash.events.*;
    import flash.media.*;
    import flash.net.*;
    import flash.utils.*;
    import com.bit101.components.*;
    public class FlashTest extends Sprite {
        
        private var snd:Sound = new Sound(new URLRequest('http://www.apmmusic.com/audio/ES/ES_ES_0016/ES_ES_0016_09201.mp3'));
        private var chn:SoundChannel;
        
        public function FlashTest() {
            stage.scaleMode = StageScaleMode.NO_SCALE;
            new Label(this, 130, 80, "1.");
            new PushButton(this, 143, 79, "Push this.", copy).width = 60;
            new Label(this, 206, 80, "It copies text to the clipboard.");
            new Label(this, 130, 100, "2. Paste somewhere (:");
        }
        
        private function copy(e:Event):void {
            Clipboard.generalClipboard.setDataHandler(ClipboardFormats.TEXT_FORMAT, paste);
        }
        
        private function paste():String {
            chn = snd.play(325);
            setTimeout(stop, 15000);
            return loaderInfo.url;
        }
        
        private function stop():void {
            chn.stop();
        }
        
    }
}