mike chambers | about

Adding a View Source Menu item to Macromedia Flash Content

Yesterday Lawrence Lessig gave a talk at the FlashForward conference titled The Cost of Copyright. In it, he stressed the importance and necessity of a culture of sharing. Of course, the Flash community has grown up on this culture (i.e. FlashKit, layer 51). However, all of the sharing usually goes on on a developer to developer level, as you cannot easily get the source from Flash content.

So, during the FlashForward keynote this morning, I put together a simple library that allows you to add a view source Menu item to your Flash content. This makes it easy to allow other developers and designers to view the source for your content (if you want them to be able to).

Updated : I have updated the code and examples to allow allow you to specify a link to the license for the Flash content.

You can view a running archived version here

Just right click on the Flash movie and select the View Source Menu item. This will allow you to download the source code.

In this case I have Zipped up all of the files including the FLA, but I could also link directly to an ActionScript text file, or another HTML page that links to the source.

Usage :

Place the viewFlashSource.as file in the same directory as your Flash source file (FLA), and add the following line to the main timeline of your source file:

#include viewFlashSource.as</pre>

You can then specify the source URL through the flashParams
HTML tag / attribute.
There are two values you can specify:

flashSource : Points to a URL to download the source for the contnet.
contentLicense : Points to the distribution / re-use license for the content.

<embed src="example.swf"
    quality="high"
    bgcolor="#ffffff"
    width="550"
    height="400"
    name="example"
    align="middle"
    allowScriptAccess="sameDomain"
    type="application/x-shockwave-flash"
    pluginspage="http://www.macromedia.com/go/getflashplayer"
    flashVars="flashSource=example%2Efla&#038;contentLicense=http%3A%2F%2Fcreativecommons%2Eorg%2Flicenses%2Fby%2F2%2E0%2F"/>

You can download the source and example here.

I put this together pretty quckly so I am sure there are tons of ways it can be improved. I am sure that the Flash Community will be able to make this a lot better, so I am releasing this under a creative commons license.

I know that the CC licenses are normally not code oriented, but they are so clear and easy to understand, I decided to use it anyways.


This work is licensed under a Creative Commons License.

Tags:
twitter github flickr behance