<?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>wu</title>
	<atom:link href="http://wu-media.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://wu-media.com</link>
	<description></description>
	<lastBuildDate>Mon, 05 Nov 2012 13:32:00 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>Extracting vector from SWFs, writing and now drawing with them</title>
		<link>http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/</link>
		<comments>http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/#comments</comments>
		<pubDate>Tue, 26 May 2009 21:13:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[PV3D]]></category>

		<guid isPermaLink="false">http://wu-media.com/?p=84</guid>
		<description><![CDATA[******************** Update: ******************** There&#8217;s now a google project for this: code.google.com/p/swfvector. I&#8217;m going to be updating this so there might be some changes to the how the whole thing works. I had a lot of positive feedback for my last project that lets you extract font glyphs out of a swf and write text using [...]]]></description>
				<content:encoded><![CDATA[<h3>******************** Update: ********************</h3>
<p><strong>There&#8217;s now a google project for this: <a href="http://code.google.com/p/swfvector" target="_blank">code.google.com/p/swfvector</a></strong>. I&#8217;m going to be updating this so there might be some changes to the how the whole thing works.<br />
</p>
<hr noshade/>
</p>
<p>I had a lot of positive feedback for my last project that lets you extract font glyphs out of a swf and write text using the flash drawing API or one of the popular 3D engines.</p>
<p>Now, this update fixes a couple of bugs and also adds support for any vector shape on the stage or the library.</p>
<p>Demo:</p>
<div class="frame">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TestVectorShapes_497070547"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="http://wu-media.com/wp-content/uploads/VectorParser/TestVectorShapes.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://wu-media.com/wp-content/uploads/VectorParser/TestVectorShapes.swf"
			name="fm_TestVectorShapes_497070547"
			width="500"
			height="300">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object></div>
<p><span id="more-84"></span></p>
<p>The syntax is very similar to the the old DynamicText class. The main difference is that for Text, you need to define a fill type and for vectors, the fill type is ignored because vector shapes have their own fill types.</p>
<p><strong>for Vector Shapes</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// extract shape from swf</span>
VectorShapes<span style="color: #000066; font-weight: bold;">.</span>extractFromLibrary<span style="color: #000000;">&#40;</span>_loader<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">data</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span><span style="color: #990000;">&quot;woman&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;snowman&quot;</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> VectorShapes<span style="color: #000066; font-weight: bold;">.</span>METHOD_CONTINUOUS_POINTS<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// draw shape</span>
VectorShapes<span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">draw</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;woman&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p><strong>for Vector Text</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// extract font data from swf</span>
VectorText<span style="color: #000066; font-weight: bold;">.</span>extractFont<span style="color: #000000;">&#40;</span><span style="color: #004993;">root</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">.</span>bytes<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// draw text</span>
<span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginFill</span><span style="color: #000000;">&#40;</span>0x0000<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
VectorText<span style="color: #000066; font-weight: bold;">.</span>write<span style="color: #000000;">&#40;</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;_Arial&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">16</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Hello World&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">10</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p><del datetime="2009-06-15T13:43:44+00:00"><br />
<strong>IMPORTANT</strong><br />
There are two methods to parse and draw vectors. METHOD_CONTINUOUS_POINTS &#038; METHOD_REGULAR.<br />
METHOD_CONTINUOUS_POINTS (the default method) parses shapes while trying to keep the points continuous. This is the best way but it does not support flat shapes (more on that later)</p>
<p>METHOD_REGULAR parses the data as it is saved in the swf. This supports all vector shapes but is slower in both parsing and rendering.</p>
<p>For best performance and to get data that is easier to work with. Use METHOD_CONTINUOUS_POINTS , but your vector shapes must not be flat. What do I mean by flat? Flat is when you collapse everything into one layer in flash and keep hitting CTRL+B until all groups are killed and everything is merged. The flash then saves this in a very compact way which makes it difficult to break out (more on that later), Anyway, this flatten shape takes a lot more passes to render and it also create a data set that is not that friendly to work with.</p>
<p>The best way to create your vector data is to have each individual shape grouped so that they don&#8217;t cut into each other. In the included source, the snowman symbol is the right way and the circles symbol is the wrong way.</p>
<p>ok. more,<br />
This is straight out of the SWF file specs:<br />
&#8220;Most vector formats allow only one fill and line style per path. The SWF file format extends<br />
this concept by allowing each edge to have its own line and fill style. This can have<br />
unpredictable results when fill styles change in the middle of a path.&#8221;</p>
<p>This is why i have two methods to parse the data.  METHOD_CONTINUOUS_POINTS  actually does it wrong, because it ignores the two fill style per edge thing. two fills per edges is never used if the shapes don&#8217;t intersect. So even though METHOD_CONTINUOUS_POINTS  is wrong, it is the preferred and default method.<br />
Another thing worth mentioning is that the flash drawing API DOES NOT support two fill per edge. instead flash saves the shapes as triangles with one common point, I&#8217;m using 0,0. It then draws these triangles erasing it&#8217;s 0,0 tail by drawing over it again. that&#8217;s the short version anyway, the whole version is a lot more complicated and i&#8217;m too lazy to go into it.<br />
</del></p>
<p><strong>Source code</strong>: <a href="http://code.google.com/p/swfvector" target="_blank">code.google.com/p/swfvector</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/feed/</wfw:commentRss>
		<slash:comments>25</slash:comments>
		</item>
		<item>
		<title>SWF file specifications</title>
		<link>http://wu-media.com/2009/05/swf-file-specifications/</link>
		<comments>http://wu-media.com/2009/05/swf-file-specifications/#comments</comments>
		<pubDate>Mon, 11 May 2009 14:01:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wu-media.com/?p=81</guid>
		<description><![CDATA[If you&#8217;re interested in parsing or building your own SWF files. here&#8217;s the file specification from Adobe, http://www.adobe.com/devnet/swf/]]></description>
				<content:encoded><![CDATA[<p>If you&#8217;re interested in parsing or building your own SWF files.</p>
<p>here&#8217;s the file specification from Adobe,</p>
<p><a href="http://www.adobe.com/devnet/swf/" target="_blank">http://www.adobe.com/devnet/swf/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wu-media.com/2009/05/swf-file-specifications/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Extracting font glyphs from SWF and Drawing with them</title>
		<link>http://wu-media.com/2009/05/extracting-font-glyphs-from-swf-and-drawing-with-them/</link>
		<comments>http://wu-media.com/2009/05/extracting-font-glyphs-from-swf-and-drawing-with-them/#comments</comments>
		<pubDate>Fri, 08 May 2009 22:32:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[PV3D]]></category>

		<guid isPermaLink="false">http://wu-media.com/?p=19</guid>
		<description><![CDATA[UPDATE: please use newer and improved version at http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/ Drawing text in flash using font glyph information is definitely not new. five3D does it, PV3D uses the five3D files to do it. and Michael Baczynski also did it. So what&#8217;s so different with my approach? I extract the font glyphs from your SWFs, so you [...]]]></description>
				<content:encoded><![CDATA[<h3>UPDATE: please use newer and improved version at <a href="http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/">http://wu-media.com/2009/05/extracting-vector-from-swfs-writing-and-now-drawing-with-them/</a></h3>
<p>Drawing text in flash using font glyph information is definitely not new. five3D does it, PV3D uses the five3D files to do it. and Michael Baczynski also did it.</p>
<p>So what&#8217;s so different with my approach?</p>
<p>I extract the font glyphs from your SWFs, so you don&#8217;t need to go through the extra step of creating a Class that has a bunch of arrays describing your font. You can now embed fonts just as you normally would, and the best part is&#8230; you can use the same fonts with regular TextFields which lowers your overall file size.</p>
<p>SWF files store fonts as a bunch of ShapeRecords the same way it does with graphics youd draw on the Stage in the Flash IDE. These ShapeRecords are composed of a bunched of lineTo, moveTo, curveTo and styles instructions. For fonts we only need the first three. since we&#8217;ll be doing they styling in code when we&#8217;re about to draw text our text.</p>
<p>Now that we&#8217;ve extracted these ShapeRecords. I&#8217;ve created a DynamicText class that draws on a Graphics target. This target can be</p>
<ol>
<li>the graphics property of a DisplayObject</li>
<li>the graphics3D property of a Shape3D in five3D</li>
<li>the graphics property of a VectorShape3D in PV3D</li>
</ol>
<p><strong>Sample code:</strong></p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
</pre></td><td class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #009900; font-style: italic;">// extract font information from swf bytes</span>
DynamicText<span style="color: #000066; font-weight: bold;">.</span>extractFontInformation<span style="color: #000000;">&#40;</span><span style="color: #004993;">root</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">loaderInfo</span><span style="color: #000066; font-weight: bold;">.</span>bytes<span style="color: #000066; font-weight: bold;">,</span> <span style="color: #0033ff; font-weight: bold;">true</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// set the style</span>
<span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">beginGradientFill</span><span style="color: #000000;">&#40;</span><span style="color: #004993;">GradientType</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">LINEAR</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span>0xff4400<span style="color: #000066; font-weight: bold;">,</span> 0x0<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span><span style="color: #000000; font-weight:bold;">1</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">1</span><span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000;">&#91;</span>0x00<span style="color: #000066; font-weight: bold;">,</span> 0xff<span style="color: #000000;">&#93;</span><span style="color: #000066; font-weight: bold;">,</span> m<span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #009900; font-style: italic;">// draw the ext</span>
DynamicText<span style="color: #000066; font-weight: bold;">.</span>write<span style="color: #000000;">&#40;</span><span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Futura Md BT&quot;</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">20</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #000000; font-weight:bold;">0</span><span style="color: #000066; font-weight: bold;">,</span> <span style="color: #990000;">&quot;Hello World&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span>
<span style="color: #004993;">graphics</span><span style="color: #000066; font-weight: bold;">.</span><span style="color: #004993;">endFill</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000066; font-weight: bold;">;</span></pre></td></tr></table></div>

<p><strong>Flash DisplayObject.graphics draw sample:</strong></p>
<div class="frame">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TestWrite_1642193208"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="http://wu-media.com/wp-content/uploads/DynamicText/TestWrite.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://wu-media.com/wp-content/uploads/DynamicText/TestWrite.swf"
			name="fm_TestWrite_1642193208"
			width="500"
			height="300">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p><span id="more-19"></span><br />
Noticed the gradient fill? because we&#8217;re using the flash drawing API, we can use beginFill, beginBitmapFill and beginGradientFill when drawing to a DisplayObject.</p>
<p>The DynamicText class has the following features,</p>
<ol>
<li>Kerning and Leading that use the same values as photoshop which makes it easier to match text styles to comps</li>
<li>TextBlock alignment of TL, T, TR, L, C, R, BL, B, and BR. TLC, LC and BLC provides centering of the text within the text block</li>
<li>Ability to align the text either using it&#8217;s baseline or it&#8217;s top or bottom edges. baseline alignment provides more accurate alignment, as the text starts from it&#8217;s baseline which also happens to be its zero point.</li>
</ol>
<p><strong>The same code can be use to draw on five3D and PV3D!</strong></p>
<p><strong>five3D Shape3D.graphics3D draw sample:</strong></p>
<div class="frame">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TestFive3D_1345053183"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="http://wu-media.com/wp-content/uploads/DynamicText/TestFive3D.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://wu-media.com/wp-content/uploads/DynamicText/TestFive3D.swf"
			name="fm_TestFive3D_1345053183"
			width="500"
			height="300">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p><strong>PV3D VectorShape3D.graphics draw sample:</strong></p>
<div class="frame">

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_TestPV3D_506619304"
			class="flashmovie"
			width="500"
			height="300">
	<param name="movie" value="http://wu-media.com/wp-content/uploads/DynamicText/TestPV3D.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://wu-media.com/wp-content/uploads/DynamicText/TestPV3D.swf"
			name="fm_TestPV3D_506619304"
			width="500"
			height="300">
	<!--<![endif]-->
		<a href="http://adobe.com/go/getflashplayer"><img src="http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" /></a><br />

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
</div>
<p>Currently, It only works with fonts that were transcoded with the flash IDE. you can still embed the fonts with the [Embed] tag, as long as it&#8217;s from a SWF that was published with the flash IDE. embedding TTF directly with the [Embed] tags breaks my parser for some reason.</p>
<p><strong>Source code</strong>: <a href="http://wu-media.com/wp-content/uploads/DynamicText/DynamicText.zip" onclick="pageTracker._trackEvent('download', 'click', 'DynamicText.zip');">Download</a></p>
]]></content:encoded>
			<wfw:commentRss>http://wu-media.com/2009/05/extracting-font-glyphs-from-swf-and-drawing-with-them/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>Hello world!</title>
		<link>http://wu-media.com/2009/05/hello-world/</link>
		<comments>http://wu-media.com/2009/05/hello-world/#comments</comments>
		<pubDate>Wed, 06 May 2009 00:56:19 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://wu-media.com/lab/?p=1</guid>
		<description><![CDATA[Welcome. I will use this space to post some experiments I do in my free time.]]></description>
				<content:encoded><![CDATA[<p>Welcome. I will use this space to post some experiments I do in my free time.</p>
]]></content:encoded>
			<wfw:commentRss>http://wu-media.com/2009/05/hello-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
