Subscribe to Tutorial Feed

Flash and PHP Bible

The Flash and PHP Bible has been released! The book can be found on Amazon or wherever fine books are sold in your area.

The Flash and PHP Bible has a forum for quick support.

Scriptplayground » tutorials » as » Utilizing the Clipboard in AS3

Utilizing the Clipboard in AS3

A quick look at saving text to the Users clipboard, with their permission.

A common use for a web application is copying contents to the clipboard. Well if you are building a Flash web app you can easily include this functionality with one line of code.

System.setClipboard("Sample text, from Flash");

While that is pretty simple, lets look at a worthwhile use for this. Imagine you have a web app that has hard to remember or even say URLs, wouldn't it be nice if you could easily allow users to share those complex links? Well with a little javascript magic and writing to the clipboard you can.

Here is the code for this proof-of-concept.

import flash.external.*;
import flash.system.System;

function grabLink():void
  System.setClipboard("Current URL: " +"window.location.href.toString"));


There you have it, a few useful examples of utilizing the clipboard in ActionScript 3. Happy coding.

Follow Scriptplayground on Twitter (@scriptplay)

Comments: Utilizing the Clipboard in AS3

No Comments have been made. Wanna be the first?
Add a comment
The ability to add new comments has been disabled in this archived version.

Main | Tutorials | Articles