Mike Chambers

code = joy

Adding a View Source Menu item to Macromedia Flash Content

with 31 comments

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.

Here is an example:


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

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&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.


Creative Commons License
This work is licensed under a Creative Commons License.

31 Responses to 'Adding a View Source Menu item to Macromedia Flash Content'

Subscribe to comments with RSS

  1. Cool one!

    Fernando Vieira

    7 Apr 05 at 2:00 pm

  2. Funny, I did the same thing, but was doing inline viewing of the code in the swf based on Object clicks and hiearchies. In essence, making something exteremely complex for no real reason. This a lot simpler and smarter.

    Kenny Bunch

    7 Apr 05 at 2:16 pm

  3. ha! Mike, that’s awesome, thanks! 8)

    I’m still trying to get a handle on what Lessig actually said yesterday. All I have to go on is Paul Festa’s reporting of it in CNET, and what I know Lessig has said in the past on other subjects.

    What opinion did you walk away with? what did other listeners report? what ideas do you think Lessig was actually trying to get across…?

    tx,
    jd

    John Dowdell

    7 Apr 05 at 3:12 pm

  4. good job – i plan on using this :)

    ericd

    7 Apr 05 at 4:41 pm

  5. Kewl, Well done this allows a central location of something I have to do so often.

    Cheers Mike

    CA

    Campbell

    7 Apr 05 at 4:52 pm

  6. Superb! Now I’m wondering if this could be built into Flex as an option.

    Manish Jethani

    7 Apr 05 at 8:09 pm

  7. this is very helpfull, thanks mike

    herdiansah

    8 Apr 05 at 1:05 am

  8. Use Player 6 with Firefox 1.0. No menu item!

    papasik

    8 Apr 05 at 3:32 am

  9. Finally, someone is listening!! This is what I stood up and said at UCON99:

    “‘The web exploded because of the ‘view source’ command. Can you recommend that people _not_ lock their Flash movies?’ To this question Lynda responded very positively, but this other guy went on about how someone took his web site, graphics and all, and made a commerce site out of it. I didn’t get the chance to respond that just about everyone has had that happen, but you’ve got to look at the bigger picture: open files are automatic tutorials. If you want Flash to be a widespread technology, then you’ve got to give people the opportunity to learn from the examples that are out there. Flash is complicated enough that the files themselves should be analyzed, not just the end product. When it comes down to it, the reason why the web grew as quickly as it did was because of the ‘View Source’ command. Do the same for Flash and it will grow just as quickly.”

    This article is available at:

    http://www.ordersomewherechaos.com/rosso/webdev/ucon/ucon99_design.shtml

    …Ross…

    Ross Olson

    8 Apr 05 at 4:30 am

  10. I really like the way there’s a ‘view license’ option… very useful if you’re providing your SWFs for free download yet want to keep them licensed and under your control.

    Paul Neave

    8 Apr 05 at 5:37 am

  11. One of the biggest advantages that Flash has is that your work is inaccessible to others. Having had my work copied/stolen in the past I find the possibility of a view source option in Flash frightening. Coldfusion, PHP, .NET, and C++ developers enjoy the advantage of having their code protected from prying eyes. I don’t see why a Flash developer should be treated differently. As ActionScript becomes a more robust programming language steps should be taken to protect the developer’s code even further. Not make it accessible to the public.

    I understand that this is an optional add-in at the moment, but I hope there are no plans of including this in future versions.

    alex

    8 Apr 05 at 11:33 am

  12. would it be useful to put a little Creative Commons “ball” – ie. tiny round badge – on the FLA? I know right-clicking around is cool for the context menu, but showing someone off the bat that you CAN right-click to get the license and source might be a usability improvement.

    ericd

    8 Apr 05 at 12:16 pm

  13. >As ActionScript becomes a more robust programming language steps should be taken to protect the developer’s code even further. Not make it accessible to the public.

    Well, that is one of the nice things about this solution, especially when you compare it to HTML / DHTML / Ajax apps. Whether or not you share your source is completely up to you. Plus, you can choose to share only parts of it. Again, it is completely up to the content developer.

    mike chambers

    mesh@macromedia.com

    mike chambers

    8 Apr 05 at 5:35 pm

  14. Mike,
    Could you give me some details on how you guys did the SynchronizedVideoPres example. What camera did you use and how
    did you get the video to blend in so nice.
    Any details would be appreciated.

    Art

    Art

    8 Apr 05 at 8:10 pm

  15. thanks mike,
    for making Flash source available via CC in the player itself. This makes the sharing thang explicit. I sometimes have to prove and establish trust with other flash dev.’s and designers before people pass on their source. I have to promise them x,y,z that their source will not go here and there. Usually i exchange some of mine for some of theirs as a sign of goodwill. The CC license solves this issue and allows for faster distribution.
    Wonderful initiative,

    j

    james

    9 Apr 05 at 6:07 am

  16. Mike Givens

    9 Apr 05 at 10:26 am

  17. hi! nice work & I have 2 check it out but,
    on Windows when I unzip the file, an error occurs. Maybe zipped on MAC OSX right?
    It’s very thankful if you help.
    thanks.

    xtra

    12 Apr 05 at 2:25 am

  18. Please share:- The fileformat licence has the restriction “…you are granted a nonexclusive license to use the Specification for the sole purposes of developing Products that output SWF”.

    Perhaps the intent of the restriction was to obstruct decompilers and the like – but they already exist.

    Please try and get this restriction lifted as it obstructs libre flash players (interpreters?) e.g. http://gplflash.sourceforge.net. Such a player would help macromedia by opening more platforms – minority platforms, potentially mobile platforms, search engines, and platforms which become unusable with the existing plugin. It would also make it possible to include flash preinstalled on Libre GNU/Linux Distributions such as Ubuntu.

    Thankyou :)
    Bob

    Bob O.

    13 Apr 05 at 6:16 am

  19. although this is a good idea (finally), i think its application pales in comparison to the w3c recommended SVG (Scalable Vector Graphics), which since it’s written in xml can be viewed in any text editor… so you can easily read the code that makes an object behave the way it does. i would love to see flash come anywhere near that level.

    gadfly

    25 Apr 05 at 2:14 pm

  20. > i think its application pales in comparison to the w3c recommended SVG (Scalable Vector Graphics), which since it’s written in xml can be viewed in any text editor.

    Well, I disagree.

    Not every developer wants his code to be available all of the time. The technique listed above give the developer control of whether or not, and how much of his code is shown.

    So, if a developer wants to make all of their code available, they can. If they want to make some of it available, they can. If they don’t want to make any of it available, they can also do that.

    As far as using a text only format to generate the content, you can also do that for Flash using the Flex framework.

    Another advantage to this solution is that the developer has control of the format the source is displayed in. So he can add color coding, documentation, etc…

    mike chambers

    mesh@macromedia.com

    mike chambers

    25 May 05 at 3:52 am

  21. Now i am using Flash MX 2004 and i want to use the program (fla file) to link to html file.Can you all help me?Thankssssssss

    This is my e-mail address : minea2004@yahoo.com

    Minea Meng

    30 May 05 at 2:19 am

  22. this is the dumbest thing I ever heard.
    SO now you expect flashers to give away code?

    Just HOW do you expect people to make money in design and development? You should take the method of Director and make the code safer.

    No wonder you have to sell the company.

    Your products are cracked in one day.
    You’re leading everyone into Orwell’s grave.

    THANKS!

    You need to get it together over there.

    Anonymous

    7 Jun 05 at 3:30 am

  23. sir ,
    please send me some basic programs how to use action script in flash.
    thanking you
    prabhu

    prabhu

    19 Jun 05 at 9:11 am

  24. waow, i’m really impressed by this trick

    thx a lot i will try this asap

    ced :D

  25. all source for action script of flash

    mahendra subba

    22 Jul 05 at 12:20 am

  26. Hello Mike,

    This can be useful to implement it to your code

    http://www.after-hours.org/foro/viewtopic.php?p=19368#19368

    Greetings

    Galileo

    24 Jul 05 at 4:09 am

  27. as a new developer who has been studying flash for about a year, who came in cold with very little programming experience I must say that the wealth of information available online has been a huge benifit to me and I kinda feel like I am catching up. There is a lot of shit to learn if you are serious about this.

    I can understand why programmers want to protect their code but it is inevidable is it not? It is hard enough to decifir even when you have the fla–I think if you can read it you can write it, no?

    gavin

    19 Sep 05 at 12:50 am

  28. Hey – nice. That’s clever. (My only beef is that people have to be told to right click…but whatareyagonnado?

    I’ve been building a little library for my own use for a while, as have many, but it hasn’t been until AS 2.0 that something like this has really seemed worthwhile to me for flash. Since the flash developers I know come from a wide range of backgrounds, sharing code is a great way of supporting the whole community. (I love math and physics, and another friend of mine has a strong Java and server-side background and both of us have considerable Director experience. I ask him about what he knows and he comes to me with questions about math-based functions.)

    Anyway, I was just looking at the Creative Commons licenses this morning, and I think they’re pretty appropriate (and most importantly easy to understand). The format drop-down on http://creativecommons.org/license/ does list interactive as an option.

    As for the nay-sayers, well, no-one is forcing anyone to give anything away. However, I think its good to keep in mind that the technology (i.e. Flash) changes so rapidly that code you create today may be out of date tomorrow. In addition, those of us from a richer academic background know that your “publications” simply add to one’s viability in the community.

    ryan

    26 Oct 05 at 6:54 am

  29. Absolutly great! I was still waiting for something like that, since years. Thx

    Heiko

    17 Nov 05 at 6:19 am

  30. How does this effect/impact the ability of Google, and others, to search through the code and increase the ability to use Flash for SEO/SEM?

  31. Interesting…
    [URL=http://audi-snow.buickgs.cn#] audi snow [/URL]
    http://audi-snow.buickgs.cn audi snow

    Prokopios

    16 Nov 07 at 11:19 pm

Leave a Reply