<?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>debit.nl &#187; Flash</title>
	<atom:link href="http://blog.debit.nl/category/flash/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.debit.nl</link>
	<description>Freelance developer</description>
	<lastBuildDate>Wed, 30 Jun 2010 21:01:07 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>MP3 encoder in Flash with Alchemy</title>
		<link>http://blog.debit.nl/2009/03/mp3-encoder-in-flash-with-alchemy/</link>
		<comments>http://blog.debit.nl/2009/03/mp3-encoder-in-flash-with-alchemy/#comments</comments>
		<pubDate>Tue, 24 Mar 2009 14:44:42 +0000</pubDate>
		<dc:creator>Bernard</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Alchemy]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.debit.nl/?p=67</guid>
		<description><![CDATA[A week ago I started playing with Adobe Alchemy. First just a few return values or simple calculations.
After a few days of playing and testing I thought it would be nice to have a MP3 Encoder in flash.
With the new Sound.extract method in Actionscript you can get raw data like a "WAV" but there is [...]]]></description>
			<content:encoded><![CDATA[<p>A week ago I started playing with Adobe Alchemy. First just a few return values or simple calculations.<br />
After a few days of playing and testing I thought it would be nice to have a MP3 Encoder in flash.<br />
With the new Sound.extract method in Actionscript you can get raw data like a "WAV" but there is no easy way to compress this data.</p>
<p>I started searching for C code which implements a MP3 Encoder and found the 8Hz MP3 implementation.<br />
I could have used LAME, but hey.. have you looked at the file count!<br />
The 8Hz implementation uses about 10 files, so it's readable. It's not the best encoder, but good enough to test the possibilities.</p>
<p>I was very surprised that the 8Hz code would compile with llvm-gcc (Alchemy)! That is a good starting point, now I only have to rewrite some code to get input from and output to Actionscript.</p>
<p>The original source used fopen to read and write files. This isn't possible with Alchemy so I replaced fopen with funopen and gave a pointer to Actionscript bytearrays.</p>
<p>The next problem I encountered was the execution timeout in Flash. When encoding large WAV files (more then 30 seconds of sound on my MacBook Pro) the flashplayer will trigger an error about exceeding the maximum execution time. I tried to alter it with the compiler option "-default-script-limits" but no luck (maybe it has something to do with Alchemy).<br />
But it forced me to take a deeper look in the encoding source. I've rewritten the layer3.c file to process a few frames and then give feedback to Actionscript. This way no timeout occurs.</p>
<p>I'm still working on speed optimization, because encoding is slow at the moment.<br />
I will keep you updated!</p>
<p>Here is the first version:</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_mp3encoder_v1_1354061673"
			class="flashmovie"
			width="260"
			height="80">
	<param name="movie" value="/wp-content/uploads/2009/03/mp3encoder_v1.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="/wp-content/uploads/2009/03/mp3encoder_v1.swf"
			name="fm_mp3encoder_v1_1354061673"
			width="260"
			height="80">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer">Get Adobe Flash player</a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
]]></content:encoded>
			<wfw:commentRss>http://blog.debit.nl/2009/03/mp3-encoder-in-flash-with-alchemy/feed/</wfw:commentRss>
		<slash:comments>39</slash:comments>
		</item>
		<item>
		<title>MP3 to SWF converter in Actionscript 3</title>
		<link>http://blog.debit.nl/2009/02/mp3-to-swf-converter-in-actionscript-3/</link>
		<comments>http://blog.debit.nl/2009/02/mp3-to-swf-converter-in-actionscript-3/#comments</comments>
		<pubDate>Fri, 13 Feb 2009 13:02:52 +0000</pubDate>
		<dc:creator>Bernard</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>

		<guid isPermaLink="false">http://blog.debit.nl/?p=31</guid>
		<description><![CDATA[A while ago I was playing with SWF generation within Flash itself.
I read the Adobe SWF specs and now I'm able to generate SWF's from FLV's and MP3's or both.
A simple Flash 10 example, haven't tested all possible MP3 rates so if someone encounters a bug, please let me know.
(Just found out that some MP3's [...]]]></description>
			<content:encoded><![CDATA[<p>A while ago I was playing with SWF generation within Flash itself.<br />
I read the Adobe SWF specs and now I'm able to generate SWF's from FLV's and MP3's or both.</p>
<p>A simple Flash 10 example, haven't tested all possible MP3 rates so if someone encounters a bug, please let me know.<br />
(Just found out that some MP3's with embedded art-work won't work... added to my TODO's).</p>

<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
			id="fm_blogmp3test_1584534861"
			class="flashmovie"
			width="250"
			height="74">
	<param name="movie" value="http://blog.debit.nl/wp-content/uploads/2009/02/blogmp3test.swf" />
	<!--[if !IE]>-->
	<object	type="application/x-shockwave-flash"
			data="http://blog.debit.nl/wp-content/uploads/2009/02/blogmp3test.swf"
			name="fm_blogmp3test_1584534861"
			width="250"
			height="74">
	<!--<![endif]-->
		
<p><a href="http://adobe.com/go/getflashplayer">Get Adobe Flash player</a></p>

	<!--[if !IE]>-->
	</object>
	<!--<![endif]-->
</object>
<p>Code snippet which writes the MP3 data to a SWF bytearray:</p>
<pre class="actionscript"><span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>mp3.<span style="color: #006600;">audioFrames</span>.<span style="color: #0066CC;">length</span> &gt; currentAudioFrame<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> needSamples:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0.001</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1000</span>/<span style="color: #66cc66;">&#40;</span>__frameRate<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>*i<span style="color: #66cc66;">&#41;</span> * audioRate;
	<span style="color: #000000; font-weight: bold;">var</span> startSamples:<span style="color: #0066CC;">int</span> = currentSamples;
	<span style="color: #000000; font-weight: bold;">var</span> audioData:ByteArray = <span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #b1b100;">while</span><span style="color: #66cc66;">&#40;</span>mp3.<span style="color: #006600;">audioFrames</span>.<span style="color: #0066CC;">length</span> &gt; currentAudioFrame &amp;&amp; currentSamples&lt; needSamples<span style="color: #66cc66;">&#41;</span>
	<span style="color: #66cc66;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">var</span> aframe:AudioFrame = AudioFrame<span style="color: #66cc66;">&#40;</span>mp3.<span style="color: #006600;">audioFrames</span><span style="color: #66cc66;">&#91;</span>currentAudioFrame<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#41;</span>;
		audioData.<span style="color: #006600;">writeBytes</span><span style="color: #66cc66;">&#40;</span>aframe.<span style="color: #006600;">frameData</span><span style="color: #66cc66;">&#41;</span>;
		currentSamples = <span style="color: #66cc66;">&#40;</span>currentAudioFrame<span style="color: #cc66cc;">+1</span><span style="color: #66cc66;">&#41;</span> * <span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">576</span>*<span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
		currentAudioFrame++;
	<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> samples:<span style="color: #0066CC;">int</span> = currentSamples - startSamples;
	<span style="color: #000000; font-weight: bold;">var</span> <span style="color: #0066CC;">seek</span>:<span style="color: #0066CC;">int</span> = startSamples ? needSamples - startSamples : <span style="color: #cc66cc;">0</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> af:AudioFrame = mp3.<span style="color: #006600;">audioFrames</span><span style="color: #66cc66;">&#91;</span>i<span style="color: #66cc66;">&#93;</span> as AudioFrame;
	_swfBytes.<span style="color: #006600;">writeShort</span><span style="color: #66cc66;">&#40;</span>createHeader<span style="color: #66cc66;">&#40;</span>SWFTags.<span style="color: #006600;">SOUNDSTREAMBLOCK</span>,<span style="color: #cc66cc;">63</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	_swfBytes.<span style="color: #006600;">writeInt</span><span style="color: #66cc66;">&#40;</span>audioData.<span style="color: #006600;">length</span><span style="color: #cc66cc;">+4</span><span style="color: #66cc66;">&#41;</span>;
	_swfBytes.<span style="color: #006600;">writeShort</span><span style="color: #66cc66;">&#40;</span>samples<span style="color: #66cc66;">&#41;</span>;
	_swfBytes.<span style="color: #006600;">writeShort</span><span style="color: #66cc66;">&#40;</span><span style="color: #0066CC;">seek</span><span style="color: #66cc66;">&#41;</span>;
	_swfBytes.<span style="color: #006600;">writeBytes</span><span style="color: #66cc66;">&#40;</span>audioData<span style="color: #66cc66;">&#41;</span>;
	_swfBytes.<span style="color: #006600;">writeShort</span><span style="color: #66cc66;">&#40;</span>createHeader<span style="color: #66cc66;">&#40;</span>SWFTags.<span style="color: #006600;">PLACE_OBJECT2</span>,<span style="color: #cc66cc;">3</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//Place frame data</span>
	_swfBytes.<span style="color: #006600;">writeByte</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
	_swfBytes.<span style="color: #006600;">writeShort</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>; <span style="color: #808080; font-style: italic;">//depth</span>
	_swfBytes.<span style="color: #006600;">writeShort</span><span style="color: #66cc66;">&#40;</span>createHeader<span style="color: #66cc66;">&#40;</span>SWFTags.<span style="color: #006600;">SHOWFRAME</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	i++;
<span style="color: #66cc66;">&#125;</span></pre>
<p>This way I write all SWF headers the correct way and not like most other code out there which uses a precompiled SWF and replace the sound object.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.debit.nl/2009/02/mp3-to-swf-converter-in-actionscript-3/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Doc? Air Local LiveDocs</title>
		<link>http://blog.debit.nl/2009/02/doc-air-local-livedocs/</link>
		<comments>http://blog.debit.nl/2009/02/doc-air-local-livedocs/#comments</comments>
		<pubDate>Thu, 12 Feb 2009 13:12:29 +0000</pubDate>
		<dc:creator>Bernard</dc:creator>
				<category><![CDATA[Actionscript]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>

		<guid isPermaLink="false">http://blog.debit.nl/?p=14</guid>
		<description><![CDATA[Doc? is an Air application that allows you to view your documentation outside of your IDE.
It supports Flash CS3 documentation, Flash CS4, Flex and ASDoc.
Searching can be done by keyword or by regular expression!
Doc? provides two plugins, one for Flash and one for Eclipse (Flex, FDT etc..). These plugins send the selected text to Doc? [...]]]></description>
			<content:encoded><![CDATA[<p>Doc? is an Air application that allows you to view your documentation outside of your IDE.<br />
It supports Flash CS3 documentation, Flash CS4, Flex and ASDoc.</p>
<p>Searching can be done by keyword or by regular expression!<br />
Doc? provides two plugins, one for Flash and one for Eclipse (Flex, FDT etc..). These plugins send the selected text to Doc? and Doc? will search it's database for matching items.</p>
<p>I love it <img src='http://blog.debit.nl/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p><a title="http://www.airdoc.be" href="http://www.airdoc.be" target="_blank">http://www.airdoc.be</a></p>
<p>Screenshot with the PV3D ASdocs imported:</p>
<div id="attachment_15" class="wp-caption alignnone" style="width: 310px"><a href="http://blog.debit.nl/wp-content/uploads/2009/02/screen_custom_asdocs.png"><img class="size-medium wp-image-15" title="Papervion API in Doc?" src="http://blog.debit.nl/wp-content/uploads/2009/02/screen_custom_asdocs-300x163.png" alt="Papervion API in Doc?" width="300" height="163" /></a><p class="wp-caption-text">Papervion API in Doc?</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.debit.nl/2009/02/doc-air-local-livedocs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

