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.

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 file in the same directory as your Flash source file (FLA), and add the following line to the main timeline of your source file:[code]#include[/code]You can then specify the source URL through the flashParamsHTML 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.[code][/code]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.<!—->

30 Responses to Adding a View Source Menu item to Macromedia Flash Content

  1. Fernando Vieira says:

    Cool one!

  2. Kenny Bunch says:

    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.

  3. John Dowdell says:

    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

  4. ericd says:

    good job – i plan on using this 🙂

  5. Campbell says:

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

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

  7. herdiansah says:

    this is very helpfull, thanks mike

  8. papasik says:

    Use Player 6 with Firefox 1.0. No menu item!

  9. Ross Olson says:

    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:…Ross…

  10. Paul Neave says:

    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.

  11. alex says:

    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.

  12. ericd says:

    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.

  13. mike chambers says:

    >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

  14. Art says:

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

  15. james says:

    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

  16. xtra says:

    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.

  17. Bob O. says:

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

  18. gadfly says:

    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.

  19. mike chambers says:

    > 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

  20. Minea Meng says:

    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?ThankssssssssThis is my e-mail address :

  21. Anonymous says:

    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.

  22. prabhu says:

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

  23. waow, i’m really impressed by this trickthx a lot i will try this asapced 😀

  24. all source for action script of flash

  25. Galileo says:

    Hello Mike,This can be useful to implement it to your code

  26. gavin says:

    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?

  27. ryan says:

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

  28. Heiko says:

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

  29. 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?