<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Richard Lord &#187; Flash</title>
	<atom:link href="http://www.richardlord.net/blog/tag/flash/feed" rel="self" type="application/rss+xml" />
	<link>http://www.richardlord.net</link>
	<description>Actionscript/Flex, PHP and Java developer</description>
	<lastBuildDate>Mon, 23 Jan 2012 17:07:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>So what are Adobe up to with Flash?</title>
		<link>http://www.richardlord.net/blog/so-what-are-adobe-up-to-with-flash</link>
		<comments>http://www.richardlord.net/blog/so-what-are-adobe-up-to-with-flash#comments</comments>
		<pubDate>Mon, 14 Nov 2011 15:32:08 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Air]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.richardlord.net/?p=883</guid>
		<description><![CDATA[It has been an interesting week in the Flash world. Various announcements and clarifications about the future of Flash, which seem to add up to Adobe will stop development of the Flash mobile browser plug-in, but mobile operating system and hardware developers are free to continue developing on top of Adobe&#8217;s existing source code if [...]]]></description>
			<content:encoded><![CDATA[<p>It has been an interesting week in the Flash world. Various <a href="http://blogs.adobe.com/conversations/2011/11/flash-focus.html">announcements</a> and <a href="http://www.mikechambers.com/blog/2011/11/11/clarifications-on-flash-player-for-mobile-browsers-the-flash-platform-and-the-future-of-flash/">clarifications</a> about the future of Flash, which seem to add up to</p>

<ol>
<li>Adobe will stop development of the Flash mobile browser plug-in, but mobile operating system and hardware developers are free to continue developing on top of Adobe&#8217;s existing source code if they wish to license it from Adobe.</li>
<li>The Flex framework will be <a href="http://blogs.adobe.com/flex/2011/11/your-questions-about-flex.html">freed from Adobe&#8217;s control</a>, and will become more open under the guidance of an as yet undecided open source foundation which will include Adobe contributors and the <a href="http://www.spoon.as/">Spoon project</a>.</li>
<li>Development of the Flash plug-in for desktop browsers continues as normal.</li>
<li>Development of Adobe Air, including publishing for mobile apps, continues as normal.</li>
<li>There&#8217;s renewed emphasis on the Flash platform as a platform for game development.</li>
<li>There has been some movement of jobs on the Flash CS Professional team, but <a href="http://www.mikechambers.com/blog/2011/11/10/flash-professional-and-the-future/">the team still exists and the next version of the product is in development</a>.</li>
</ol>

<p>There&#8217;s been a lot of hand-wringing as Flash developers struggle to figure out what this means for them. I don&#8217;t propose to resolve that here &#8211; what this means for you depends on both your skill-set and your job. But I guess if I had one bit of advice it would be, if Actionscript is the only development language you know it&#8217;s well past time for you to diversify your skills. Learning a second programming language makes you a better programmer in general, and learning a third, fourth, etc becomes easier with each language. I have lost track of the number of programming languages I have learnt, but each one has made me a better programmer.</p>

<p>What follows is merely my personal take on the situation. Make of it what you will. I&#8217;ll start with an important question.</p>

<h3>Why did Adobe buy Macromedia?</h3>

<p>For some time I&#8217;ve been meaning to write a blog post about why Adobe bought Macromedia (it only happened six years ago <img src='http://www.richardlord.net/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> ). I don&#8217;t actually know the answer, but I have my suspicions and they&#8217;re different from those I hear voiced elsewhere.</p>

<p>I suspect it is true that Adobe bought Macromedia to get their hands on Flash. This is a common assumption, and I see no reason for it to be wrong. There was nothing else in the Macromedia toolkit that mattered much to Adobe, except perhaps Dreamweaver which is now taking on renewed significance.</p>

<p>I suspect that the Flash platform tools (Flash Builder and Flash CS Professional) were not the target. These tools are for developers, unlike Adobe&#8217;s other tools, and are built atop a free plug-in which Adobe also have to develop and maintain. I also suspect the Flash platform generates far smaller profit margins than Photoshop, Illustrator and InDesign.</p>

<p>One reasonable suspicion is that Adobe bought Macromedia simply so that someone else didn&#8217;t. They didn&#8217;t want Macromedia&#8217;s design tools in the hands of a company with deeper pockets. This may well be true.</p>

<p>But my suspicion is, back when Adobe bought Macromedia, they looked at the application landscape and concluded, as many others did, that the future of applications was as web-based services. They needed a platform on which to develop web-based versions of Photoshop, Illustrator and InDesign and Flash was an obvious choice for that platform. By buying Macromedia, Adobe gained control of Flash&#8217;s development, and hence of the platform they proposed to use for web-based applications. This enabled them to move development of the Flash player in directions that they needed.</p>

<p>Unfortunately for Adobe, while they were following this strategy the world moved in a different direction. Six years later, the present is not web-based applications, it&#8217;s small, cheap, sometimes throwaway, native applications that use the web as a data source and nothing more.</p>

<p>Adobe were not the only ones caught out by this &#8211; Apple themselves, when they launched the iPhone, thought most phone apps would be web apps. They were just more agile in moving with the times and switching emphasis to native apps.</p>

<p>Adobe are making their move now. In fact, they have been for the last couple of years, but it&#8217;s only now that killing bits of the Flash platform (specifically the mobile browser plug-in) has become part of that move.</p>

<h3>What now?</h3>

<p>So now Adobe find themselves with a profitable, but not massively so, set of products in the Flash platform that don&#8217;t fit neatly within their product portfolio. I wonder if Adobe now wish they hadn&#8217;t bought Macromedia, but that&#8217;s all in the past. They need to make the best of the current situation.</p>

<p>Killing Flash on the desktop would be madness, although I suspect maintaining Flash&#8217;s 98% desktop penetration is now less important, and it&#8217;s a decline in this figure that will be the first indication of Flash&#8217;s true decline. But, while there&#8217;s money to be made and a reasonable profit margin available, the Flash plug-in and the tools surrounding it will continue.</p>

<p>On top of that, the one thing the development world needs is a good cross-platform mobile app development platform. Unity3d provides a good tool for cross-platform game development, but the best cross-platform tools for general app development are mediocre at best. Adobe Air is currently one of those mediocre platforms, and with sufficient work it could become a good platform for mobile development. I hope it does. It has a lot of merit.</p>

<p>It sounds like Adobe may have identified this need and the potential of Air, so it&#8217;s just possible that Actionscript developers have a bright future ahead of them. Time will tell.</p>

<p>Meanwhile, if you&#8217;re an Actionscript developer it&#8217;s high time to diversify in whatever direction makes most sense to you. Javascript/Unity3d/Objective-C/Ruby&#8230; there&#8217;s lots of interesting stuff out there. Go and have fun. But you don&#8217;t have to abandon Flash and Actionscript just yet &#8211; Adobe haven&#8217;t.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/so-what-are-adobe-up-to-with-flash/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>What project will replace the Flex framework?</title>
		<link>http://www.richardlord.net/blog/what-project-will-replace-the-flex-framework</link>
		<comments>http://www.richardlord.net/blog/what-project-will-replace-the-flex-framework#comments</comments>
		<pubDate>Tue, 13 Apr 2010 14:58:47 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Reflex]]></category>
		<category><![CDATA[Robotlegs]]></category>
		<category><![CDATA[Swiz]]></category>

		<guid isPermaLink="false">http://www.richardlord.net/?p=534</guid>
		<description><![CDATA[<p>In <a href="/blog/is-the-flash-platform-waiting-for-a-spring-moment">my previous post</a> I discussed the idea that a project might emerge to replace the Flex framework, in a similar manner to Spring replacing EJB in the Java world. Although I am not in a position to predict what that project will be, I did mention some characteristics that I think the project will have. They were</p>

<ol>
<li>It will start as something simple, with a strong foundation and the potential to grow.</li>
<li>It will have some very strong developers at its core.</li>
<li>It will have at least one project member with an ability to market effectively to the developer community.</li>
<li>It will be open source.</li>
<li>Its roadmap will develop through open discussion with the community.</li>
<li>It will have a very active developer community around it.</li>
<li>It's probably a project that has already begun.</li>
</ol>

<p>I can think of three excellent projects that meet most or all of these criteria. Whether any of them will one day replace the flex framework depends on many things, including in two cases whether the developers would even want to do such a thing. Here are the projects...</p>]]></description>
			<content:encoded><![CDATA[<p>In <a href="/blog/is-the-flash-platform-waiting-for-a-spring-moment">my previous post</a> I discussed the idea that a project might emerge to replace the Flex framework, in a similar manner to Spring replacing EJB in the Java world. Although I am not in a position to predict what that project will be, I did mention some characteristics that I think the project will have. They were</p>

<ol>
<li>It will start as something simple, with a strong foundation and the potential to grow.</li>
<li>It will have some very strong developers at its core.</li>
<li>It will have at least one project member with an ability to market effectively to the developer community.</li>
<li>It will be open source.</li>
<li>Its roadmap will develop through open discussion with the community.</li>
<li>It will have a very active developer community around it.</li>
<li>It&#8217;s probably a project that has already begun.</li>
</ol>

<p>I can think of three excellent projects that meet most or all of these criteria. Whether any of them will one day replace the flex framework depends on many things, including in two cases whether the developers would even want to do such a thing. Here are the projects.</p>

<h3>Reflex</h3>

<p>The most obvious candidate is <a href="http://reflex.io/">Reflex</a>. It actually styles itself as a Flex replacement. It&#8217;s also not a first generation project, having evolved from <a href="http://blog.benstucki.net/">Ben Stucki</a>&#8216;s experiences developing <a href="http://code.google.com/p/openflux/">OpenFlux</a> and <a href="http://jacwright.com/">Jacob</a> &#038; <a href="http://www.xtyler.com/">Tyler</a> Wright&#8217;s experiences developing the <a href="http://www.flightxd.com/flightframework/">Flight Framework</a>. Reflex is designed as a straight improvement on the way Flex is designed. A key element in this is the use of containment rather than inheritance when creating the component architecture.</p>

<p>The result is aiming to be a simplified, lightweight, extendible component architecture with core features from Flex like MXML and CSS all in a tiny (~50kB) package.</p>

<p>The project is in its early stages but appears to be progressing well. The three core developers are all experienced and talented. Ben knows how to make a noise in the development community so they have that angle covered too.</p>

<h3>Robotlegs</h3>

<p>Like the original Spring for Java, <a href="http://www.robotlegs.org/">Robotlegs</a> (which is built on top of <a href="http://github.com/tschneidereit/SwiftSuspenders">SwiftSuspenders</a>) is a lightweight architecture built around a dependency injection container. Currently it complements the Flex framework, but if, like Spring, Robotlegs grew to cover more aspects of development it could perhaps be the foundation for a new approach to simplifying the development process. Put simply, maybe dependency injection could be the foundation for a component architecture.</p>

<p>Robotlegs was founded by <a href="http://shaun.boyblack.co.za/blog/">Shaun Smith</a> and it has skilled developers, an active and open community and, in <a href="http://joelhooks.com/">Joel Hooks</a>, at least one developer who has an aptitude for promoting the project to the wider world. Moving beyond an elegant micro-architecture into the world of Flex replacement therapy would be a big leap but I suspect the Robotlegs team would be up for it if they want the challenge.</p>

<h3>Swiz</h3>

<p><a href="http://swizframework.org/">Swiz</a> started life as a personal project for <a href="http://cdscott.blogspot.com/">Chris Scott</a>, but has evolved into a community project with a number of strong developers. It&#8217;s also changed at its core from a dependency injection based lightweight architecture to a metadata processing architecture, with a dependency injection container and event bus architecture built atop it. This puts Swiz in a position to build an architecture around metadata as well as Actionscript/MXML/CSS. Adding additional metadata processors to the Swiz toolset might open up new architectures to replace the traditional Flex model.</p>

<p>Swiz has had issues with documentation (it&#8217;s limited and updated intermittently) but the team are getting better at telling the community what&#8217;s going on and what their roadmap is, and they are quick to respond to questions which mitigates many of the documentation issues.</p>

<h3>Only three?</h3>

<p>There are other projects I could have mentioned but from those I know these three most closely match my criteria above. I also like and am excited by all three of these projects.</p>

<p>What would be your candidate for a project with a bright future and the potential to grow into a Flex replacement?</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/what-project-will-replace-the-flex-framework/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Is The Flash Platform waiting for a Spring moment?</title>
		<link>http://www.richardlord.net/blog/is-the-flash-platform-waiting-for-a-spring-moment</link>
		<comments>http://www.richardlord.net/blog/is-the-flash-platform-waiting-for-a-spring-moment#comments</comments>
		<pubDate>Thu, 08 Apr 2010 12:59:31 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[Frameworks]]></category>

		<guid isPermaLink="false">http://www.richardlord.net/?p=525</guid>
		<description><![CDATA[<p>I've dipped my toe back in the Java world recently, and I'm reminded of some interesting Java history that may be echoed in Flash's future.</p>

<p>Back in the distant mist of Java's past, most large Java web projects were built using something called <a href=”http://en.wikipedia.org/wiki/Enterprise_JavaBean”>Enterprise JavaBeans</a>. EJB was a complex framework developed by Sun, the developers of Java itself (with some input from IBM). EJB had a number of good things going for it, but some developers also thought that the architecture and APIs were too complex.</p>

<p>Then a smart guy called Rod Johnson wrote <a href="http://www.amazon.com/Expert-One-Design-Development-Programmer/dp/0764543857/">a book about an idea</a>, and he created <a href="http://www.springsource.org/about">a small framework called Spring</a> to illustrate that idea, and the Java world started to change...</p>]]></description>
			<content:encoded><![CDATA[<h3>Background</h3>

<p>I&#8217;ve dipped my toe back in the Java world recently, and I&#8217;m reminded of some interesting Java history that may be echoed in Flash&#8217;s future.</p>

<p>Back in the distant mist of Java&#8217;s past, most large Java web projects were built using something called <a href=”http://en.wikipedia.org/wiki/Enterprise_JavaBean”>Enterprise JavaBeans</a>. EJB was a complex framework developed by Sun, the developers of Java itself (with some input from IBM). EJB had a number of good things going for it, in particular</p>
<ul>
<li>It had respected advocates in Sun and IBM</li>
<li>It addressed some real and difficult problems</li>
</ul>
<p>but some developers also thought that the architecture and APIs were too complex.</p>

<p>Then a smart guy called Rod Johnson wrote <a href="http://www.amazon.com/Expert-One-Design-Development-Programmer/dp/0764543857/">a book about an idea</a>, and he created <a href="http://www.springsource.org/about">a small framework called Spring</a> to illustrate that idea, and the Java world started to change. Now, EJB is no longer the de-facto standard in the Java world. A smaller, lighter, more agile, more flexible framework called Spring has taken over. There are some who still use EJB (and EJB has become smaller and lighter in response to Spring&#8217;s success) but Spring is the framework in demand.</p>

<h3>What has all this to do with Flash?</h3>

<p>Replace Java with Flash, replace Sun with Adobe, and replace EJB with Flex and you might see a parallel in which Flash is ripe for a smaller, lighter, more agile, more flexible framework than Flex.</p>

<p>That shouldn&#8217;t be seen as a suggestion that Flex is rubbish – far from it. I use Flex every day and am often amazed at how good it is. Yet just as often I&#8217;m annoyed by its faults. Because Flex isn&#8217;t perfect, and its imperfections run very deep. All the new stuff in Flex 4 is great (most of it at least), but it keeps getting bigger, more unwieldy, more complicated.</p>

<p>So I suggest that, as with Java and EJB a few years ago, Flash is ready for a newer, lighter framework to evolve to replace Flex. I don&#8217;t know what that framework is but I suspect it will have most of the following attributes</p>
<ol>
<li>It will start as something simple, with a strong foundation and the potential to grow.</li>
<li>It will have some very strong developers at its core.</li>
<li>It will have at least one project member with an ability to market effectively to the developer community.</li>
<li>It will be open source.</li>
<li>Its roadmap will develop through open discussion with the community.</li>
<li>It will have a very active developer community around it.</li>
<li>It&#8217;s probably a project that has already begun.</li>
</ol>
<p>It may be one project, or it may be a merger of many. Maybe it&#8217;s that little project you&#8217;ve been working on in your spare time. Whatever it is, I suspect a couple of years from now we&#8217;ll have a serious alternative to rival the Flex framework.</p>

<p>There is also <a href="/blog/what-project-will-replace-the-flex-framework">a follow-up post looking at some projects that might evolve to replace Flex</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/is-the-flash-platform-waiting-for-a-spring-moment/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Showing DHTML content on top of flash content</title>
		<link>http://www.richardlord.net/blog/showing-dhtml-content-on-top-of-flash-content</link>
		<comments>http://www.richardlord.net/blog/showing-dhtml-content-on-top-of-flash-content#comments</comments>
		<pubDate>Wed, 18 Apr 2007 10:19:07 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[DHTML]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/showing-dhtml-content-on-top-of-flash-content/</guid>
		<description><![CDATA[<p>I get asked about this often in my training courses so I thought it might be good to air the issue here. I'm not the first to post about this online but for some reason many people aren't finding the solution so here it is.</p>
<p>How to show DHTML content (e.g. a pull-down menu) on top of flash content?...</p>
]]></description>
			<content:encoded><![CDATA[<p>I get asked about this often in my <a href="http://www.bigroom.co.uk/about/training/">training courses</a> so I thought it might be good to air the issue here. I&#8217;m not the first to post about this online but for some reason many people aren&#8217;t finding the solution so here it is.</p>

<h3>The problem</h3>

<p>How to show DHTML content (e.g. a pull-down menu) on top of flash content?</p>

<h3>The cause</h3>

<p>By default, browser plug-in or activeX content (from now on I&#8217;ll refer to plug-in content when meaning both) is displayed in its own window. It doesn&#8217;t look like it&#8217;s in it&#8217;s own window because the window in question has no borders, title bar or anything else we normally associate with a window, but from the computer&#8217;s point of view it is a window. Windows occupy rectangular areas of the screen and each window is displayed above or below other windows.</p>

<p>In the case of plug-in content, the plug-in renders its content in a borderless window that is displayed above the content of the browser window. So, by default, the flash content will always be displayed above all the html page content, regardless of the z-index setting in the css style for the content.</p>

<p>The simple reasons for this are speed and simplicity &#8211; the plug-in gets to display whatever it likes in it&#8217;s area of the screen without the need to merge this content with the html content displayed by the browser</p>

<h3>The solution</h3>

<p>Fortunately, flash has a setting to prevent the plug-in content being displayed in its own window. The object and embed tags have a parameter/attribute called the <a href="http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&#038;file=00000852.html">&#8220;wmode&#8221;</a>. This parameter takes one of three values &#8211; &#8220;window&#8221;, &#8220;opaque&#8221; or &#8220;transparent&#8221;. The value controls how the plug-in displays the content with respect to the default behaviour described above. Most modern browsers support the wmode parameter (<a href="http://www.adobe.com/cfusion/knowledgebase/index.cfm?id=tn_14201">see Adobe&#8217;s list of supported browsers</a>).</p>

<p>The &#8220;window&#8221; setting is the default and behaves as above, with the flash content rendered in its own borderless window above the page content. The other two settings, &#8220;opaque&#8221; and &#8220;transparent&#8221;, render the flash content within the browser window itself, with transparent showing the flash movie with a transparent background so elements behind it can be seen. Choosing either of these settings will enable you to display the DHTML content above the flash content. I&#8217;d recommend opaque unless you really need transparent, since transparent can cause some slowdown in the flash movie playback.</p>

<p>So, in brief, set wmode to opaque and then you can display the DHTML content above the flash using the z-index css property to control the layering.</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/showing-dhtml-content-on-top-of-flash-content/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Protecting a swf</title>
		<link>http://www.richardlord.net/blog/protecting-a-swf</link>
		<comments>http://www.richardlord.net/blog/protecting-a-swf#comments</comments>
		<pubDate>Wed, 21 Mar 2007 13:54:55 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Security]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/protecting-a-swf/</guid>
		<description><![CDATA[<p>In my training courses I often get asked about protecting swf movies. There's two sides to this - one is encrypting the code to make it hard for others to decompile and use, and the other is limiting where the swf can be used from so that users can't simply place your swf on their website.</p>

<p>There are a number of commercial and free obfuscating and encryption tools to help protect your code so I'm not going to say any more about them (maybe in a later post). Here's a few ideas for how to limit where the swf movie may be used.</p>
]]></description>
			<content:encoded><![CDATA[<p>In my training courses I often get asked about protecting swf movies. There&#8217;s two sides to this &#8211; one is encrypting the code to make it hard for others to decompile and use, and the other is limiting where the swf can be used from so that users can&#8217;t simply place your swf on their website.</p>

<a name="obfuscators"></a><p>There are a number of commercial and free obfuscating and encryption tools to help protect your code, three of which are <a href="http://www.genable.com/aso.html">ASO</a>, <a href="http://www.amayeta.com/software/swfencrypt/">SWFEncrypt</a> and <a href="http://www.kindisoft.com/">SecureSWF</a>, so I&#8217;m not going to say any more about them (maybe in a later post). Here&#8217;s a few ideas for how to limit where the swf movie may be used.</p>

<h2>What domain is the swf running in?</h2>

<p>The swf can check to see what domain it&#8217;s running in and exit if the domain isn&#8217;t allowed. You can do this with a function like this</p>

<pre class="code">function isDomainAllowed( allowed:Array ):Boolean
{
    var lc:LocalConnection = new LocalConnection();
    var domain:String = lc.domain();

    for( var i:Number = 0; i < allowed.length; ++i )
    {
        if( domain == allowed[i] )
        {
            return true;
        }
    }
    for( var i:Number = 0; i < allowed.length; ++i )
    {
        if( domain.substr( - ( allowed[i].length + 1 ) ) )
                        == "." + allowed[i] )
        {
            return true;
        }
    }
    return false;
}</pre>

<p>This function receives  an array of allowed domains and checks the domain in which the movie is running against the array. If the swf is running in any of  the domains or a subdomain of any of them then the function returns true, otherwise it returns false.</p>

<p>You use it like this</p>

<pre class="code">var domains:Array = new Array(
    "bigroom.co.uk",
    "example.com",
    "localhost"      // allow local testing
    );
if( isDomainAllowed( domains ) )
{
    gotoAndPlay( "content" ); // play the movie
}
else
{
    gotoAndPlay( "forbidden" ); // display some error message
                                // - more about this later
}</pre>

<h2>What flash player is the swf running in?</h2>

<p>In the previous method, the localhost value in the array is to allow testing of the movie locally, in the Flash development environment or in a local web page. It also allows users to download the swf and run it locally or to load it into a projector. If you want to ban all local use of the swf then you can just remove the localhost value from the array of allowed domains. However, if you want to restrict the local use to some instances only (e.g. the Flash IDE only) you need to test what flash player the movie is running in. That works like this</p>

<pre class="code">function isPlayerAllowed( allowed:Array ):Boolean
{
    var player:String = System.capabilities.playerType;

    for( var i:Number = 0; i < allowed.length; ++i )
    {
        if( player == allowed[i] )
        {
            return true;
        }
    }
    return false;
}</pre>

<p>The possible values of System.capabilities.playerType are</p>
<ul>
<li>ActiveX - the active-x control used in Internet Explorer</li>
<li>PlugIn - the plug-in used in other web browsers </li>
<li>StandAlone - the stand alone player and projectors</li>
<li>External - the test movie mode in the Flash IDE</li>
</ul>

<p>So the isPlayerAllowed function is used like this</p>

<pre class="code">var players:Array = new Array(
    "ActiveX",
    "PlugIn",
    "External"      // allow local testing
    );
if( isPlayerAllowed( domains ) )
{
    gotoAndPlay( "content" ); // play the movie
}
else
{
    gotoAndPlay( "forbidden" ); // display some error message
}</pre>

<h2>Load a file from the server</h2>

<p>A third option is to try to load a file from your web server. If the load fails, abort
the movie. Something like this</p>

<pre class="code">function testWithServer( callback:Function ):Void
{
    var receiver:LoadVars = new LoadVars();
    receiver.onLoad = callback;
    receiver.load( "http://example.com/testswf.txt" );
}</pre>

<p>Which is used like this</p>

<pre class="code">function testResult( success:Boolean ):Void
{
    gotoAndPlay( "content" ); // play the movie
}
else
{
    gotoAndPlay( "forbidden" ); // display some error message
}

stop();
testWithServer( testResult );</pre>

<p>This is quite basic - The file can be an empty text file - it needs no content. The function succeeds if the file can be loaded and thus is dependent only on the cross-domain policy for the domain hosting the test file that's loaded. If the policy allows the movie to load the file then it succeeds. The advantage to this is that we can update the allowed domains for our swf simply by modifying the cross-domain policy file on the server - there's no need to touch the flash movie. <a href="http://www.adobe.com/livedocs/flash/8/main/00001621.html">(More info on cross-domain policy files here)</a></p>

<p>It's important that the url is not a relative url - that would enable someone to bypass the security simply by placing an appropriate file on their own server.</p>

<p>There are many ways that this method can be enhanced, for example</p>

<ul>
<li>by sending the domain to the server and recieving a response that indicates whether the domain is allowed (and logging any disallowed domains)</li>
 
<li>by generating a unique id each time the page containing the flash movie is loaded and passing it to the movie via the FlashVars. The swf then passes this back to the server when asking permission to run. The server allows each id to be used once only.</li>

<li>by using encryption in the query and response (see <a href="http://www.meychi.com/archive/000031.php">ASCrypt</a> for some actionscript encryption code).</li>
</ul>

<p>But the basic system of an absolute URL and one or more (you can give each swf a unique policy file that it loads via the System.security.loadPolicyFile() method) cross-domain policy files is enough in many cases.</p>

<h2>Conclusion</h2>

<p>Each of these three ideas can be used individually or all together. Personally, I like the way that the first two are contained within the flash movie and require no special content on the server. Alternatively, the last method lets you update the allowed domains without editing the flash movie itself so each have their advantages. Note that if your source code can be decompiled then all these tests can be circumvented by simply removing the test altogether, so you may want to take another look at those <a href="#obfuscators">encryptors and obfuscators</a>.</p>

<h2>What to do if playback isn't allowed?</h2>

<p>If your test reveals that the movie shouldn't be allowed to play, then what should you do? There's two basic policies you could turn to</p>

<ul>
<li>Tell the user what's going on - display a message like "This movie/game/whatever can be viewed at http://example.com/funkyswf.html".</li>
<li>Cause the player to crash - a simple <code>while( true );</code> creates an infinite loop to achieve this.</li>
</ul>

<p>I choose between these options based on specific circumstances. The second option gives a potential thief fewer clues as to what's going on, but you could use the first option to tell the thief where to legitimately obtain the swf (and how much it will cost).</p>

<p>I hope this is useful to you. What security techniques do you use?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/protecting-a-swf/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Free flash preloader components</title>
		<link>http://www.richardlord.net/blog/free-flash-preloader-components</link>
		<comments>http://www.richardlord.net/blog/free-flash-preloader-components#comments</comments>
		<pubDate>Wed, 07 Mar 2007 11:25:11 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Preloader]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/free-flash-preloader-components/</guid>
		<description><![CDATA[<p>Some time ago I created a set of components for creating preloaders. They are designed so that the graphics, style and text feedback can all be modified by the user without writing any code.</p>

<p>I used to charge a small fee for them but they're getting a bit long in the tooth now. Since updating them doesn't fit with my current plans I'm making them available for free so please help yourself...</p>]]></description>
			<content:encoded><![CDATA[<p>Some time ago I created a set of components for creating preloaders. They are designed so that the graphics, style and text feedback can all be modified by the user without writing any code.</p>

<p>I used to charge a small fee for them but they&#8217;re getting a bit long in the tooth now. Since updating them doesn&#8217;t fit with my current plans I&#8217;m making them available for free so please help yourself.</p>

<p>The components are not compiled so you can read and modify the code. They are written in Actionscript 1 and they work with Flash MX, Flash MX 2004 and Flash 8.</p>

<p><a href="/files/preloader.zip"><b>Download the components</b></a> &#8211; includes the components, documentation and examples</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/free-flash-preloader-components/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Custom context menu with keyboard shortcuts in Flash</title>
		<link>http://www.richardlord.net/blog/custom-context-menu-with-keyboard-shortcuts-in-flash</link>
		<comments>http://www.richardlord.net/blog/custom-context-menu-with-keyboard-shortcuts-in-flash#comments</comments>
		<pubDate>Wed, 13 Dec 2006 10:02:06 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Context menu]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/custom-context-menu-with-keyboard-shortcuts-in-flash/</guid>
		<description><![CDATA[<p>I was very pleased that Strictly Sudoku was Adobe's Site of the Day last Friday.
In creating the site, the aim was to make the best sudoku site on the web and this
award suggests we have gone some way towards that. What follows is a description of how I implemented the custom context menu and keyboard shortcuts on that site...</p>]]></description>
			<content:encoded><![CDATA[<p>I was very pleased that <a href="http://www.strictlysudoku.com/">Strictly Sudoku</a> was Adobe&#8217;s Site of the Day last Friday. In creating the site, the aim was to make the best sudoku site on the web and this award suggests I have gone some way towards that.</p>

<p>I wanted the sudoku game in this site to be as simple as possible to use and to that end I implemented a context menu (accessed via right-click in Windows and control-click in Mac OS) that contained most of the command options, along with keyboard shortcuts for many of these commands. This supplements any buttons that may be available.</p>

<p>The Flash Player already has a context menu, but this can be modified to remove some of the default options and to add your own options.</p>

<p>To modify the context menu you have to create a new ContextMenu object and modify that. I chose to extend the context menu with my own class and use that to modify the menu as follows.</p>

<pre class="code">class SudokuMenu extends ContextMenu
{
    public function SudokuMenu()
    {
        super( onSelect );
        hideBuiltInItems();

        customItems.length = 0;
        customItems.push( new MenuPen() );
        customItems.push( new MenuHowDoing() );
        customItems.push( new MenuPause() );
        customItems.push( new MenuPrint() );
        customItems.push( new MenuRestart() );
        customItems.push( new MenuShowSolution() );
        customItems.push( new MenuSpinner() );
        customItems.push( new MenuTimer() );
        customItems.push( new MenuErrorCells() );
        customItems.push( new MenuAbout() );
    }

    public function onSelect( obj:Object, menu:ContextMenu ):Void
    {
        for( var i:String in customItems )
        {
            customItems[i].Prepare();
        }
    }
}</pre>

<p>First we call the parent constructor passing it the method to call when the user right-clicks to display the menu. This method will be used to prepare the menu items for display.</p>

<p>hideBuiltInItems() is used to clear out the default menu items. You can&#8217;t clear them all but this will clear most of them leaving just the Settings and About Flash Player items.</p>

<p>I then clear any custom items by setting the length of the customItems array to zero.</p>

<p>The customItems array holds any custom items we want in our menu so the next few lines push all the custom items into this array.</p>

<p>Finally, the onSelect method is called when the user right clicks in the flash movie &#8211; just before the menu is displayed. This lets us customise the menu for viewing. So, in the onSelect we call the Prepare method of each menu item.</p>

<p>Every custom menu item extends Flash&#8217;s ContextMenuItem class. The pause menu item looks like this.</p>

<pre class="code">class MenuPause extends ContextMenuItem
{
    public function MenuPause()
    {
        super( "Options    esc", onSelect );
        Key.addListener( this );
    }

    public function onSelect():Void
    {
        _global.sudokuManager.TogglePause();
    }

    public function Prepare():Void
    {
        if( _global.sudokuManager.IsPaused() )
        {
            caption = "Resume    esc";
        }
        else
        {
            caption = "Options    esc";
        }
    }

    public function onKeyDown():Void
    {
        if( Key.getCode() == Key.ESCAPE )
        {
            onSelect();
        }
    }
}</pre>

<p>All items in the context menu must be ContextMenuItem objects, so my MenuPause class extends this class to add additional functionality.</p>

<p>The constructor calls it&#8217;s parent object&#8217;s constructor with the default menu caption and the method which should be called when the menu item is selected. The caption contains the keyboard shortcut code separated from the caption by a tab &#8211; this pushes the keyboard shortcut to align right in the menu display.</p>

<p>Also, in the constructor I add this object as a listener to the keyboard so I can catch the keyboard shortcut.</p>

<p>The onSelect function is called when the menu item is selected so this contains the necessary code to pause or unpause the game.</p>

<p>The prepare method is called from the SudokuMenu object above just before displayingteh menu. The pause item checks whether the game is currently paused and sets its caption to Options or Resume accordingly.</p>

<p>Finally, the onKeyDown method checks whether the keyboard shortcut for this option was pressed and if so it calls the onSelect method to do the appropriate action for this menu item.</p>

<p>And that&#8217;s it. All the other menu items are implemented in a similar manner. The result is a more flexible interface that can be seen <a href="http://www.strictlysudoku.com/puzzle.php?puzzlenum=14431">on the Strictly Sudoku site</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/custom-context-menu-with-keyboard-shortcuts-in-flash/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>IE7 and Firefox2 search providers for Flash &amp; Coldfusion LiveDocs</title>
		<link>http://www.richardlord.net/blog/ie7-firefox2-search-providers-flash-coldfusion</link>
		<comments>http://www.richardlord.net/blog/ie7-firefox2-search-providers-flash-coldfusion#comments</comments>
		<pubDate>Wed, 08 Nov 2006 17:39:36 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Browser search]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/ie7-firefox2-search-providers-flash-coldfusion/</guid>
		<description><![CDATA[<p>I've made some more search providers for the Internet Explorer 7 and Firefox 2 navigation bar search boxes. These scripts search various sections of the Adobe LiveDocs, specifically Flash 8, Flex 2, Flash Media Server 2 and Coldfusion MX 7 docs...</p>]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve made some more search providers for the Internet Explorer 7 and Firefox 2 navigation bar search boxes. These scripts search various sections of the Adobe LiveDocs, specifically Flash 8, Flex 2, Flash Media Server 2 and Coldfusion MX 7 docs. You can get them all <a href="http://www.bigroom.co.uk/products/ie7-firefox2-search-providers/">here</a>.</p>

<p>When I created the search providers for PHP and MySQL, I really wanted one for the Flash LiveDocs too, but the LiveDocs search is driven from JavaScript which makes it hard (impossible?) to do the search directly from a simple URL query.</p>

<p>The solution I&#8217;ve come up with is instead to use Google&#8217;s site search to search the LiveDocs. I&#8217;ve also added Google&#8217;s &#8220;I&#8217;m feeling lucky&#8221; feature to some of the scripts to jump straight to the first result from the search. This works well in most cases. Google&#8217;s coverage of the Flex 2 documentation seems weak but I&#8217;m hoping this will improve over time.</p>

<p>Just click the appropriate link below to add the search you want.</p>

<ul>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/coldfusion7docsearch.xml');">Coldfusion MX 7 LiveDocs Search</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/coldfusion7docsingle.xml');">Coldfusion MX 7 LiveDocs search &#8211; jump directly to top result</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/flash8docsearch.xml');">Flash 8 LiveDocs Search</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/flash8docsingle.xml');">Flash 8 LiveDocs search &#8211; jump directly to top result</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/fms2docsearch.xml');">Flash Media Server 2 LiveDocs Search</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/fms2docsingle.xml');">Flash Media Server 2 LiveDocs search &#8211; jump directly to top result</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/flex2docsearch.xml');">Flex 2 LiveDocs Search</a></li>
<li><a href="#" onclick="window.external.AddSearchProvider('http://www.bigroom.co.uk/search/flex2docsingle.xml');">Flex 2 LiveDocs search &#8211; jump directly to top result</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/ie7-firefox2-search-providers-flash-coldfusion/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flash player update adds full-screen support</title>
		<link>http://www.richardlord.net/blog/flash-player-full-screen</link>
		<comments>http://www.richardlord.net/blog/flash-player-full-screen#comments</comments>
		<pubDate>Fri, 13 Oct 2006 15:52:32 +0000</pubDate>
		<dc:creator>Richard</dc:creator>
				<category><![CDATA[All]]></category>
		<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Full-screen]]></category>

		<guid isPermaLink="false">http://www.bigroom.co.uk/blog/flash-player-full-screen/</guid>
		<description><![CDATA[<p>Adobe have released a beta update for the flash player on Adobe Labs. Among the new features are support for a full-screen mode on the web, so it won't be long now before we have full-screen flash video and other content on web sites. A brief summary of using full-screen mode in Actionscript 2 follows...</p>]]></description>
			<content:encoded><![CDATA[<p>Adobe have released a beta update for the flash player on Adobe Labs. Among the new features are support for a full-screen mode on the web, so it won&#8217;t be long now before we have full-screen flash video and other content on web sites. The player version number is 9,0,18,60. It and the documentation are available on <a href="http://labs.adobe.com/technologies/flashplayer9/">Adobe Labs</a>. A brief summary of using full-screen mode in Actionscript 2 follows.</p>

<p>Flash movies can&#8217;t start in full-screen mode and can only switch to full-screen mode in response to a user action &#8211; either a button click or a key press. The facility to use full-screen mode is governed by a parameter in the object and embed tags. The parameter name is allowFullScreen and it defaults to false. Set it to true to enable full-screen mode -</p>

<pre class="code">&lt;object classid=&quot;clsid:d27cdb6e-ae6d-11cf-96b8-444553540000&quot;
codebase=&quot;http://fpdownload.macromedia.com/pub/shockwave/cabs
/flash/swflash.cab#version=9,0,18,0&quot; width=&quot;550&quot;
height=&quot;400&quot;&gt;
   &lt;param name=&quot;allowFullScreen&quot; value=&quot;true&quot; /&gt;
   &lt;param name=&quot;movie&quot; value=&quot;fullscreen.swf&quot; /&gt;
   &lt;embed src=&quot;fullscreen.swf&quot; allowFullScreen=&quot;true&quot;
      width=&quot;550&quot; height=&quot;400&quot;
      type=&quot;application/x-shockwave-flash&quot;
      pluginspage=&quot;http://www.macromedia.com/go/getflashplayer&quot; /&gt;
&lt;/object&gt;</pre>

<p>On its own, this isn&#8217;t enough to enter full-screen mode. You also need a little bit of Actionscript -</p>

<pre class="code">Stage.displayState = &quot;fullScreen&quot;;</pre>

<p>and to switch back from full-screen mode -</p>

<pre class="code">Stage.displayState = &quot;normal&quot;;</pre>

<p>As mentioned before, this code must be run in response to a key press or a button click for it to work.</p>

<p>Unfortunately, if you just type this in and compile your movie, you&#8217;ll get an error. that&#8217;s because Flash 8 knows nothing about the new displayState property on the Stage class. There&#8217;s two ways around this. The first is to add the appropriate code to the Stage intrinsic class, so open the Stage class file in your flash installation &#8211; for the English version this is at Flash 8/First&nbsp;Run/Classes/FP8/Stage.as &#8211; and add the following line of code after the other property declarations -</p>

<pre class="code">static var displayState:String;</pre>

<p>The second, uglier but easier, option is to simply use the associative array syntax to access the new property, so use</p>

<pre class="code">Stage[&quot;displayState&quot;] = &quot;fullScreen&quot;;</pre>

<p>and</p>

<pre class="code">Stage[&quot;displayState&quot;] = &quot;normal&quot;;</pre>

<p>There&#8217;s more info, demos and AS3 instructions in the <a href="http://labs.adobe.com/wiki/index.php/Flash_Player:9:Update:Full-Screen_Mode">Adobe Labs Wiki</a>. Have fun.</p>]]></content:encoded>
			<wfw:commentRss>http://www.richardlord.net/blog/flash-player-full-screen/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

