<?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>Karoshi Ethos &#187; ActionScript</title>
	<atom:link href="http://karoshiethos.com/tag/actionscript/feed/" rel="self" type="application/rss+xml" />
	<link>http://karoshiethos.com</link>
	<description>Navigating the treacherous waters of interactive technology</description>
	<lastBuildDate>Fri, 11 May 2012 20:46:35 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Serving a Flash Socket Policy File From Processing</title>
		<link>http://karoshiethos.com/2010/03/26/serving-a-flash-socket-policy-file-from-processing-org/</link>
		<comments>http://karoshiethos.com/2010/03/26/serving-a-flash-socket-policy-file-from-processing-org/#comments</comments>
		<pubDate>Sat, 27 Mar 2010 03:52:53 +0000</pubDate>
		<dc:creator>Rob Ruchte</dc:creator>
				<category><![CDATA[How To]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[AS3]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Kung-Foo]]></category>
		<category><![CDATA[Processing]]></category>

		<guid isPermaLink="false">http://karoshiethos.com/?p=500</guid>
		<description><![CDATA[Last night I spent way too long trying to get AS3 to communicate with a simple socket server I wrote in Processing. I've done this kind of thing before and seemed to recall that it was pretty simple. But in the meantime, Adobe, in an effort to be more secure, has changed the Flash player [...]]]></description>
			<content:encoded><![CDATA[<p>Last night I spent way too long trying to get AS3 to communicate with a simple socket server I wrote in <a href="http://processing.org/" target="_blank">Processing</a>. I've done this kind of thing before and seemed to recall that it was pretty simple. But in the meantime, Adobe, <a href="http://www.adobe.com/devnet/flashplayer/articles/flash_player9_security_update.html#socket_policy" target="_blank">in an effort to be more secure</a>, has changed the Flash player to require a "<a href="http://www.adobe.com/devnet/flashplayer/articles/fplayer9_security_04.html" target="_blank">socket policy file</a>". The socket policy file is very similar to the familiar crossdomain.xml file that defines security permissions for HTTP access. Unfortunately, the socket policy file must either be sent on demand from the sockets that the player is attempting to access, <a href="http://www.adobe.com/devnet/flashplayer/articles/socket_policy_files.html" target="_blank">or from port 843</a> on the host that the player is attempting to connect to. If all you want to do is run a quick and dirty socket server and have Flash clients connect to it, this is all a huge PITA.</p>
<p>Since <a href="http://e-articles.info/e/a/title/Privileged-Ports-of-a-UNIX-machine/" target="_blank">ports below 1024 require root permissions</a> in order for processes to use them on OS X, and I didn't want to run some other server process just to serve policy files, I needed to kludge a way to send the policy file from my nice, elegant socket server every time a client connected and requested a policy file. The example below is a simplified version, as it only listens on one port - the project I was working on was basically a proxy from one SWF to another, so I had two socket servers that needed to listen for the requests for a policy file and respond. In this example, the server listens for connections on port 5208, and simply echoes incoming data from the client to System.out, and has some visual feedback in the window. When the incoming message contains the string "policy-file-request" (the entire message from Flash will be
<policy-file-request/> terminated with a null char), we simply spit back the XML for a wide-open socket policy, followed by a null char (This is required, or the Flash player will not accept the policy file. This is what tied me in knots last night. RTFM!)</p>
<pre class="syntax brush-java">import processing.net.*;

int bgLevel = 0;
int port = 5208;
Server server;

String flashDomainPolicy = &quot;&lt;?xml version=\&quot;1.0\&quot;?&gt;&quot;
                              +&quot;&lt;cross-domain-policy xmlns:xsi=\&quot;http://www.w3.org/2001/XMLSchema-instance\&quot; xsi:noNamespaceSchemaLocation=\&quot;http://www.adobe.com/xml/schemas/PolicyFileSocket.xsd\&quot;&gt;&quot;
                              +&quot;&lt;allow-access-from domain=\&quot;*\&quot; to-ports=\&quot;*\&quot; secure=\&quot;false\&quot; /&gt;&quot;
                              +&quot;&lt;site-control permitted-cross-domain-policies=\&quot;all\&quot; /&gt;&quot;
                              +&quot;&lt;/cross-domain-policy&gt;&quot;;

void setup ()
{
  size(200, 200);
  server = new Server(this, port);
  background(bgLevel);
}

void draw ()
{
  Client client = server.available();

  if (client !=null)
  {
    String message = trim(client.readString());

    if (message != null)
    {
      if (match(message,&quot;policy-file-request&quot;) != null)
      {
        sendFlashPolicy(server);
      }
      else
      {
        server.write(message);
        System.out.println(message);

        // Change the background color to indicate message activity
        bgLevel = 255;
      }
    }
  }

  // Fade to black
  if (bgLevel&gt;1)
  {
    bgLevel-=2;
    background(bgLevel);
  }
}

void sendFlashPolicy(Server socketServer)
{
    socketServer.write(flashDomainPolicy+char(0));
    System.out.println(&quot;Sending Flash policy file&quot;);
}</pre>
<p>You can test this without a Flash client by firing up the sketch and telnetting to the port. Any strings you send will be echoed to System.out, unless you send the string "policy-file-request" in your message, which will result in the server sending the policy XML to you. You should be able to connect a Flash client to this server and start communicating right away.</p>
]]></content:encoded>
			<wfw:commentRss>http://karoshiethos.com/2010/03/26/serving-a-flash-socket-policy-file-from-processing-org/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Mangled Kerning in Flash HTML Text</title>
		<link>http://karoshiethos.com/2008/07/26/mangled-kerning-in-flash-html-text/</link>
		<comments>http://karoshiethos.com/2008/07/26/mangled-kerning-in-flash-html-text/#comments</comments>
		<pubDate>Sat, 26 Jul 2008 16:20:10 +0000</pubDate>
		<dc:creator>jon</dc:creator>
				<category><![CDATA[Things that are broken]]></category>
		<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Kerning]]></category>
		<category><![CDATA[TextFields]]></category>

		<guid isPermaLink="false">http://karoshiethos.com/?p=30</guid>
		<description><![CDATA[Work long enough with Flash and dynamic textfields, and you'll probably run into this one—words that appear to have an extra and/or missing space preceding or following them, often when a link is introduced via the &#60;A&#62; tag. It doesn't happen with every font (I was using Helvetica Condensed—other condensed fonts seemed faulty as well), [...]]]></description>
			<content:encoded><![CDATA[<p>Work long enough with Flash and dynamic textfields, and you'll probably run into this one—words that appear to have an extra and/or missing space preceding or following them, often when a link is introduced via the &lt;A&gt; tag. It doesn't happen with every font (I was using Helvetica Condensed—other condensed fonts seemed faulty as well), it doesn't happen with every link (certain letter combinations have a high degree of reproducability, others no problem).</p>
<p>I spent half a day narrowing it down. Since my text was originating from XML, it first masqueraded as some sort of entity or character encoding problem. I messed with TextFormat and StyleSheet (mutually exclusive by-the-way). A later wild goose test-case showed that flipping the autosize flag off made the issue disappear. Fine, but I <strong>need</strong> autosizing.</p>
<p>When <a href="http://www.smashingideas.com" target="_blank">Andreas Heim</a> pointed out the solution, I remembered I'd run into this before: "Do you happen to be using 'Anti-alias for readability?'" Sure enough, flip it to "Anti-alias for animation" and all's well with the world.</p>
<p>I can only hope that the Flash 10 player addresses this bug. With all the work that's gone into its type rendering features in this revision, I'd certainly assume so. I'll post some test cases / screenshots in the next update.</p>
<p><a href="http://karoshiethos.com/wp-content/uploads/2008/08/mangledkerning.zip">Download example FLA &amp; SWF</a></p>
<p><em>Update</em>: Screenshot of effected swf. Verified <strong>broken </strong>in Flash 10 beta player. <img src='http://karoshiethos.com/wp-includes/images/smilies/icon_sad.gif' alt=':(' class='wp-smiley' /> </p>
<p><img src="http://karoshiethos.com/wp-content/uploads/2008/08/textfield_link_test_v2.png" alt="" /></p>
]]></content:encoded>
			<wfw:commentRss>http://karoshiethos.com/2008/07/26/mangled-kerning-in-flash-html-text/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

