<?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>Jozef Chúťka&#039;s blog</title>
	<atom:link href="http://blog.yoz.sk/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.yoz.sk</link>
	<description>My life, my work</description>
	<lastBuildDate>Wed, 10 Mar 2010 13:37:55 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>What fontName to use with embedding?</title>
		<link>http://blog.yoz.sk/2010/03/what-fontname-to-use-with-embedding/</link>
		<comments>http://blog.yoz.sk/2010/03/what-fontname-to-use-with-embedding/#comments</comments>
		<pubDate>Wed, 10 Mar 2010 13:37:55 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[Best Practices]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[font-face]]></category>
		<category><![CDATA[fontFamily]]></category>
		<category><![CDATA[fontStyle]]></category>
		<category><![CDATA[fontWeight]]></category>
		<category><![CDATA[Helvetica]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1218</guid>
		<description><![CDATA[
This article extends &#8220;Embedding fonts bold vs. black&#8221; post. Sometimes it may be tricky to guess correct fontName with your font. Compilator works with different fontNames than what Flash IDE shows you. Lets say you want to embed fonts from .swf (library) file into .css file. In Flash IDE, properties panel for TextInput, character Family [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/arialBlack-200x134.png" alt="" title="arialBlack" width="200" height="134" class="alignleft size-medium wp-image-676" /></p>
<p>This article extends &#8220;<a href="http://blog.yoz.sk/2009/11/embedding-fonts-bold-vs-black/">Embedding fonts bold vs. black</a>&#8221; post. Sometimes it may be tricky to guess correct fontName with your font. Compilator works with different fontNames than what Flash IDE shows you. Lets say you want to embed fonts from .swf (library) file into .css file. In Flash IDE, properties panel for TextInput, character Family and Style stand for something totaly different that what you gonna need with correct fontName value later in .css file. In fact solution is very easy.</p>
<p><span id="more-1218"></span></p>
<p>For example, for Helvetica font family, Flash IDE offers one Family called &#8220;Helvetica Neue LT Pro&#8221; with different styles &#8220;65 Medium&#8221;, &#8220;55 Roman&#8221;:</p>
<p><img src="http://blog.yoz.sk/wp-content/uploads/helveticaFlashIDE.jpg" alt="" title="helveticaFlashIDE" width="567" height="309" class="alignnone size-full wp-image-1219" /></p>
<p>Here comes the tricky part. When it comes to .css you may want to use:</p>
<pre class="brush: css;">@font-face
{
    src: url(&quot;assets/fonts.swf&quot;);
    fontFamily: &quot;Helvetica Neue LT Pro&quot;;
    fontStyle: &quot;65 Medium&quot;;
}
</pre>
<p>&#8230; but compiler would stop you saying:</p>
<pre class="brush: plain;">font 'Helvetica Neue LT Pro' with normal weight and regular style not found
Unable to transcode assets/fonts.swf</pre>
<p>&#8230; or something similar.</p>
<p>So how to find out what is the correct fontFamily for compilator? Thankfully, there is an easy help. Locate your .ttf (.otf) file and open it. In my case I have used default system font viewer (Windows XP), but I am sure you can use any solid font viewer application:</p>
<p><img src="http://blog.yoz.sk/wp-content/uploads/helveticaViewer.png" alt="" title="helveticaViewer" width="337" height="277" class="alignnone size-full wp-image-1225" /></p>
<p>&#8230;and there you find your familyName. Now you can embed fonts:</p>
<pre class="brush: css;">@font-face
{
    src: url(&quot;assets/fonts.swf&quot;);
    fontFamily: &quot;HelveticaNeueLT Pro 65 Md&quot;;
}

@font-face
{
    src: url(&quot;assets/fonts.swf&quot;);
    fontFamily: &quot;HelveticaNeueLT Pro 55 Roman&quot;;
    fontWeight: bold;
}</pre>
<p>Notice there is different fontFamily and fontWeight (normal vs. bold) used for each font. If you try to use something else (change fontWeight) with these font-face specifications, compiler would stop you again. The fontFamily thing seems to be clear, but for now the thing with fontWeight remains mystery for me (viewer is not saying a thing about it). Flash IDE font family and style are also suggested somehow mysteriously.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/03/what-fontname-to-use-with-embedding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inviting Friends into Facebook Application</title>
		<link>http://blog.yoz.sk/2010/03/inviting-friends-into-facebook-application/</link>
		<comments>http://blog.yoz.sk/2010/03/inviting-friends-into-facebook-application/#comments</comments>
		<pubDate>Tue, 09 Mar 2010 11:51:26 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[facebook api]]></category>
		<category><![CDATA[FBML]]></category>
		<category><![CDATA[request-form]]></category>
		<category><![CDATA[serverFbml]]></category>
		<category><![CDATA[XFBML]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1182</guid>
		<description><![CDATA[
Those are hard times. Facebook discontinued support for Notifications.send method March 1, 2010. Calling this method returns error code 3 (Unknown method). Instead, developers are directed to use other communication channels. From those some are not yet even a part of facebook-actionscript-api yet (dashboard) other not published from facebook (invites) and those that may work [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/facebookInvites.jpg" alt="" title="facebookInvites" width="200" height="172" class="alignleft size-full wp-image-1183" /></p>
<p>Those are hard times. Facebook discontinued support for <a href="http://wiki.developers.facebook.com/index.php/Notifications.send">Notifications.send</a> method March 1, 2010. Calling this method returns error code 3 (Unknown method). Instead, developers are directed to use other <a href="http://wiki.developers.facebook.com/index.php/Communication_Channels_Best_Practices">communication channels</a>. From those some are not yet even a part of <a href="http://code.google.com/p/facebook-actionscript-api/">facebook-actionscript-api</a> yet (<a href="http://wiki.developers.facebook.com/index.php/Dashboard_API">dashboard</a>) other not published from facebook (<a href="http://wiki.developers.facebook.com/index.php/Roadmap_Invites">invites</a>) and those that may work via api are experimental and may change any day (<a href="http://wiki.developers.facebook.com/index.php/Dashboard.publishActivity">activities</a>).</p>
<p>Excluding <a href="http://wiki.developers.facebook.com/index.php/Roadmap_Stream">streams</a> as communication channel, the only usable way, these days, to acquire some new facebook application users is using <a href="http://wiki.developers.facebook.com/index.php/Fb:request-form">&lt;Fb:request-form&gt;</a> (part of <a href="http://wiki.developers.facebook.com/index.php/Category:FBML_tags">FBML</a>). When your application is IFrame, you may find interesting that you are able to use FBML within your HTML files. In order to make this happen, you have to use <a href="http://wiki.developers.facebook.com/index.php/Fb:serverFbml">&lt;Fb:serverFbml&gt;</a> (renders the FBML on a Facebook server inside an iframe). Now, lets see how to open request form in your Facebook <strong>Iframe</strong> application:</p>
<p><span id="more-1182"></span></p>
<p>First thing you need is <a href="http://wiki.developers.facebook.com/index.php/Cross_Domain_Communication_Channel">Cross Domain Communication Channel</a> file . It is simple static file, you should name it xd_receiver.htm</p>
<pre class="brush: xml;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot;
   &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; &gt;
&lt;head&gt;
    &lt;title&gt;Cross-Domain Receiver Page&lt;/title&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/XdCommReceiver.js?2&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>now your application index.html file with request form:</p>
<pre class="brush: xml;">&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xmlns:fb=&quot;http://www.facebook.com/2008/fbml&quot;&gt;
&lt;head&gt;&lt;/head&gt;
&lt;body&gt;
&lt;script src=&quot;http://static.ak.connect.facebook.com/js/api_lib/v0.4/FeatureLoader.js.php&quot; type=&quot;text/javascript&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot;&gt;
	window.onload = function()
	{
		FB_RequireFeatures([&quot;XFBML&quot;], function()
		{
			FB.Facebook.init(&quot;*YOUR*API*KEY*HERE*&quot;, &quot;xd_receiver.htm&quot;);
		});
	};
&lt;/script&gt;

&lt;fb:serverFbml style=&quot;width: 750px;&quot;&gt;
	&lt;script type=&quot;text/fbml&quot;&gt;
		&lt;fb:fbml&gt;
			&lt;fb:request-form action=&quot;http://www.google.com&quot; method=&quot;POST&quot; invite=&quot;true&quot; type=&quot;TestApp&quot;
				content=&quot;Join my app &amp;lt;fb:req-choice url=&amp;quot;http://apps.facebook.com/facebookyoztest/&amp;quot; label=&amp;quot;Go Test app&amp;quot; /&amp;gt;&quot;&gt;
				&lt;fb:multi-friend-selector showborder=&quot;false&quot; actiontext=&quot;Invite your friends to use Test app.&quot;&gt;
			&lt;/fb:request-form&gt;
		&lt;/fb:fbml&gt;
	&lt;/script&gt;
&lt;/fb:serverFbml&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Place both files in the same folder (or specify xd_receiver.htm path correctly in FB.Facebook.init() function). Now make sure you setup your application correctly: </p>
<pre class="brush: plain;">Canvas Callback URL: http://facebook.yoz.sk/Test/
Connect URL: http://facebook.yoz.sk/Test/
Base Domain: yoz.sk
Canvas URL: http://apps.facebook.com/facebookyoztest/
FBML/iframe: iframe
Application Type: Website</pre>
<p>Now request form should be generated when you visit canvas url.</p>
<p><img src="http://blog.yoz.sk/wp-content/uploads/facebookInvites2.jpg" alt="" title="facebookInvites2" width="400" height="220" class="alignnone size-full wp-image-1197" /></p>
<p>Important:</p>
<ul>
<li><strong>Your application must be iframe type</strong></li>
<li><strong>URLs used in this article are not to be used in your apps</strong></li>
<li><strong>This article was written and is valid on March 9, 2010</strong></li>
</ul>
<p>Continue reading:</p>
<ul>
<li>[deprecated] <a href="http://wiki.developers.facebook.com/index.php/Notifications.send">Notifications.send</a></li>
<li>[deprecated] <a href="http://wiki.developers.facebook.com/index.php/Notifications.sendRequest">Notifications.sendRequest</a></li>
<li>[May 2010] <a href="http://wiki.developers.facebook.com/index.php/Roadmap_Invites">Roadmap Invites</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Dashboard.addNews">Dashboard.addNews</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Dashboard.multiAddNews">Dashboard.multiAddNews</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Multi_friend_selector">Multi friend selector</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Communication_Channels_Best_Practices">Communication Channels Best Practices</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Developer_Roadmap">Developer Roadmap</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/XFBML">XFBML</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Fb:serverFbml">Fb:serverFbml</a></li>
<li><a href="http://wiki.developers.facebook.com/index.php/Fb:request-form">Fb:request-form</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/03/inviting-friends-into-facebook-application/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Fixing Z-sorting in Papervision 3D (update)</title>
		<link>http://blog.yoz.sk/2010/03/fixing-z-sorting-in-papervision-3d/</link>
		<comments>http://blog.yoz.sk/2010/03/fixing-z-sorting-in-papervision-3d/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 15:23:12 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[BasicRenderEngine]]></category>
		<category><![CDATA[Cube]]></category>
		<category><![CDATA[DisplayObject3D]]></category>
		<category><![CDATA[Papervision 3D]]></category>
		<category><![CDATA[QuadrantRenderEngine]]></category>
		<category><![CDATA[sortMode]]></category>
		<category><![CDATA[ViewportLayer]]></category>
		<category><![CDATA[ViewportLayerSortMode]]></category>
		<category><![CDATA[z-sort]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1139</guid>
		<description><![CDATA[
It may be very tricky thing to get papervision 3d scene rendered correctly event for the simpliest objects. In my case, I have created simple 3d scene with few primitive objects (8 cubes). Cubes are positioned close to each other to create shape of bigger cube + some small space between. Cubes are added into [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/cube3-200x200.png" alt="" title="cube3" width="200" height="200" class="alignleft size-medium wp-image-1145" /></p>
<p>It may be very tricky thing to get papervision 3d scene rendered correctly event for the simpliest objects. In my case, I have created simple 3d scene with few primitive objects (8 cubes). Cubes are positioned close to each other to create shape of bigger cube + some small space between. Cubes are added into wrapping DisplayObject3D, later wrapper is added to scene in order to make it easy to rotate cubes as a group. Camera targets the center of the scene. In the demo, there are 3 sliders to rotate wrapping object in each x, y, z axis + two buttons that rotates wrapper in the problematic possition (based on z-sorting fix approach). Finally I managet it to work, you can follow my approaches below. Notice the changes are not cummulative, each approach comes from original Application.mxml. All of the ideas collected online from blogs, forums etc.</p>
<p><span id="more-1139"></span></p>
<p style="clear:both;">Application.mxml code</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot;
    applicationComplete=&quot;init()&quot; enterFrame=&quot;loop()&quot;
    frameRate=&quot;40&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import org.papervision3d.objects.DisplayObject3D;
    import org.papervision3d.objects.primitives.Cube;
    import org.papervision3d.materials.ColorMaterial;
    import org.papervision3d.materials.utils.MaterialsList;
    import org.papervision3d.render.BasicRenderEngine;
    import org.papervision3d.cameras.Camera3D;
    import org.papervision3d.scenes.Scene3D;
    import org.papervision3d.view.Viewport3D;

    private var viewport:Viewport3D;
    private var scene:Scene3D = new Scene3D();
    private var camera:Camera3D = new Camera3D(60, 10, 1000);
    private var renderer:BasicRenderEngine= new BasicRenderEngine();
    private var wrapper:DisplayObject3D = new DisplayObject3D();

    private var black:ColorMaterial = new ColorMaterial(0x000000, 1);
    private var white:ColorMaterial = new ColorMaterial(0xffffff, 1);

    private function init():void
    {
        viewport = new Viewport3D(width, height, false);
        container.addChild(viewport);

        black.opposite = true;
        white.opposite = true;

        var materialList:MaterialsList = new MaterialsList();
        materialList.addMaterial(black, &quot;top&quot;);
        materialList.addMaterial(black, &quot;bottom&quot;);
        materialList.addMaterial(white, &quot;left&quot;);
        materialList.addMaterial(white, &quot;right&quot;);
        materialList.addMaterial(black, &quot;front&quot;);
        materialList.addMaterial(black, &quot;back&quot;);

        var cube:Cube;
        for(var x:uint = 0; x &lt; 2; x++)
        for(var y:uint = 0; y &lt; 2; y++)
        for(var z:uint = 0; z &lt; 2; z++)
        {
            cube = new Cube(materialList, 100, 100, 100, 1, 1, 1, Cube.ALL);
            cube.x = x * 100 * 1.05;
            cube.y = y * 100 * 1.05;
            cube.z = z * 100 * 1.05;
            wrapper.addChild(cube);
        }

        scene.addChild(wrapper);

        camera.lookAt(cube);
        camera.zoom = 100;
    }

    private function loop():void
    {
        if(!viewport)
            return;

        wrapper.rotationX = rx.value;
        wrapper.rotationY = ry.value;
        wrapper.rotationZ = rz.value;

        renderer.renderScene(scene, camera, viewport);
    }

    private function position1():void
    {
        rx.value = 216;
        ry.value = 101;
        rz.value = 0;
    }

    private function position2():void
    {
        rx.value = 333;
        ry.value = 19;
        rz.value = 360;
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:UIComponent id=&quot;container&quot; width=&quot;100%&quot; height=&quot;100%&quot; /&gt;
&lt;mx:HBox&gt;
    &lt;mx:VSlider id=&quot;rx&quot; value=&quot;216&quot; minimum=&quot;0&quot; maximum=&quot;360&quot; liveDragging=&quot;true&quot;/&gt;
    &lt;mx:VSlider id=&quot;ry&quot; value=&quot;101&quot; minimum=&quot;0&quot; maximum=&quot;360&quot; liveDragging=&quot;true&quot;/&gt;
    &lt;mx:VSlider id=&quot;rz&quot; value=&quot;0&quot; minimum=&quot;0&quot; maximum=&quot;360&quot; liveDragging=&quot;true&quot;/&gt;
    &lt;mx:VBox&gt;
        &lt;mx:Button label=&quot;position 1&quot; click=&quot;position1()&quot; /&gt;
        &lt;mx:Button label=&quot;position 2&quot; click=&quot;position2()&quot; /&gt;
    &lt;/mx:VBox&gt;
&lt;/mx:HBox&gt;
&lt;/mx:Application&gt;</pre>
<p>renders corrupted on this position:
<p>
<img src="http://blog.yoz.sk/wp-content/uploads/cube1.png" alt="" title="cube1" width="400" height="400" class="alignnone size-full wp-image-1141" /></p>
<hr />
<p>&#8230; then I defined camera clipping, but no success (someone&#8217;s suggestion, but it seems <a href="http://blog.zupko.info/?p=170">clipping is to be used for different purpose</a>):</p>
<pre class="brush: as3;">camera.useClipping = true; // before line 57</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube1.png" alt="" title="cube1" width="400" height="400" class="alignnone size-full wp-image-1141" /></p>
<hr />
<p>&#8230; adding quarterFaces(), some more vertices for each vertex is not gonna save the day:</p>
<pre class="brush: as3;">cube.quarterFaces(); // before line 50</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube4.png" alt="" title="cube4" width="400" height="400" class="alignnone size-full wp-image-1148" /></p>
<hr />
<p>&#8230; adding ViewportLayer-s for each object fixed first problematic view, but corrupted another:</p>
<pre class="brush: as3;">import org.papervision3d.view.layer.ViewportLayer;
...
var viewportLayer:ViewportLayer; // before line 42
...
viewportLayer = viewport.getChildLayer(cube, true); // before line 51
viewportLayer.addDisplayObject3D(cube);</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube2.png" alt="" title="cube2" width="400" height="400" class="alignnone size-full wp-image-1143" /></p>
<hr />
<p>&#8230; useOwnContainer should (and does) work the same as adding ViewportLayers:</p>
<pre class="brush: as3;">cube.useOwnContainer = true; // before line 50</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube2.png" alt="" title="cube2" width="400" height="400" class="alignnone size-full wp-image-1143" /></p>
<hr />
<p>&#8230; finally, layering + sortMode seems to work fine, and fast <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre class="brush: as3;">import org.papervision3d.view.layer.util.ViewportLayerSortMode;
...
viewport.containerSprite.sortMode = ViewportLayerSortMode.ORIGIN_SORT; // before line 28
...
cube.useOwnContainer = true; // before line 50</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube3.png" alt="" title="cube3" width="400" height="400" class="alignnone size-full wp-image-1145" /></p>
<hr />
<p>update Mar 5, 2010: &#8230; another successful attempt:</p>
<pre class="brush: as3;">cube.meshSort = DisplayObject3D.MESH_SORT_FAR; // before line 50</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube3.png" alt="" title="cube3" width="400" height="400" class="alignnone size-full wp-image-1145" /></p>
<hr />
<p>&#8230; ultimate method for correct z-sorting and rendering is in using slower <a href="http://papervision3d.googlecode.com/svn/trunk/as3/trunk/docs/org/papervision3d/render/QuadrantRenderEngine.html">QuadrantRenderEngine</a> <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre class="brush: as3;">import org.papervision3d.render.QuadrantRenderEngine;
...
private var renderer:QuadrantRenderEngine //replace line 19
        = new QuadrantRenderEngine(QuadrantRenderEngine.CORRECT_Z_FILTER);</pre>
<p><img src="http://blog.yoz.sk/wp-content/uploads/cube3.png" alt="" title="cube3" width="400" height="400" class="alignnone size-full wp-image-1145" /></p>
<hr />
<p>Where to go from where:</p>
<ul>
<li><a href="http://papervision2.com/fix-z-sorting-issues-using-viewport-layers/">Fix Z-Sorting Issues Using Viewport Layers</a></li>
<li><a href="http://papervision2.com/fixing-z-sorting-issues-with-the-quadrantrenderengine/">Fix Z-Sorting issues with the QuadrantRenderEngine</a></li>
<li><a href="http://blog.zupko.info/?p=170">Papervision3D now featuring frustum clipping</a></li>
<li><a href="http://blog.zupko.info/?p=177">Using QuadTrees in Papervision3D</a></li>
<li><a href="http://forum.papervision3d.org/viewtopic.php?f=14&#038;t=1414&#038;start=0">More z-sorting problems</a></li>
<li><a href="http://n4.nabble.com/Using-layers-for-z-sorting-td781405.html#a781405">Forcing depths (forceDepth, screenDepth)</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/03/fixing-z-sorting-in-papervision-3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Pixel Bender Disco</title>
		<link>http://blog.yoz.sk/2010/02/pixel-bender-disco/</link>
		<comments>http://blog.yoz.sk/2010/02/pixel-bender-disco/#comments</comments>
		<pubDate>Thu, 18 Feb 2010 11:24:09 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[BitmapData]]></category>
		<category><![CDATA[fps]]></category>
		<category><![CDATA[pixel bender]]></category>
		<category><![CDATA[Shader]]></category>
		<category><![CDATA[ShaderJob]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1117</guid>
		<description><![CDATA[
While playing with pixel bender, I created some simple sahders that when combined, reminds me of winamp visualizations effects. Feel free to use any in your own projects.

Click and drag mouse to make some disco effects. (wait while page header flash finishes loading so it runs smoothly)

&#60;?xml version=&#34;1.0&#34; encoding=&#34;utf-8&#34;?&#62;
&#60;mx:Application xmlns:mx=&#34;http://www.adobe.com/2006/mxml&#34; layout=&#34;absolute&#34;
    enterFrame=&#34;enterFrame()&#34; [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/pixelBenderDisco.jpg" alt="" title="pixelBenderDisco" width="200" height="100" class="alignleft size-full wp-image-1124" /></p>
<p>While playing with pixel bender, I created some simple sahders that when combined, reminds me of winamp visualizations effects. Feel free to use any in your own projects.</p>
<p><span id="more-1117"></span></p>
<p style="clear:both;">Click and drag mouse to make some disco effects. (wait while page header flash finishes loading so it runs smoothly)</p>
<p><iframe width="100%" height="300" style="border:none;" src="http://blog.yoz.sk/examples/pixelBenderDisco/"></iframe></p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;absolute&quot;
    enterFrame=&quot;enterFrame()&quot; applicationComplete=&quot;init()&quot;
    backgroundColor=&quot;#ffffff&quot; frameRate=&quot;50&quot;
    mouseMove=&quot;mouseMoveHandler(event)&quot;
    mouseDown=&quot;mouseDownHandler(event)&quot;
    mouseUp=&quot;mouseUpHandler(event)&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    private var drawing:Boolean = false;
    private var color:uint = 0x0;
    private var bitmap:Bitmap = new Bitmap();
    private var lineX:Number = 0;

    [Bindable]
    private var fps:Number = 0;
    private var fpsDate:Date = new Date();
    private var fpsFrames:uint = 0;

    [Bindable]
    private var rotationTime:uint = 0;

    [Bindable]
    private var blurTime:uint = 0;

    [Bindable]
    private var colorizeTime:uint = 0;

    [Bindable]
    private var twirlTime:uint = 0;

    [Embed(source=&quot;../pbj/rotation.pbj&quot;, mimeType=&quot;application/octet-stream&quot;)]
    private static const ROTATION_CLASS:Class;
    private static const ROTATION_SHADER:Shader = new Shader(new ROTATION_CLASS());

    [Embed(source=&quot;../pbj/blur.pbj&quot;, mimeType=&quot;application/octet-stream&quot;)]
    private static const BLUR_CLASS:Class;
    private static const BLUR_SHADER:Shader = new Shader(new BLUR_CLASS());

    [Embed(source=&quot;../pbj/colorize.pbj&quot;, mimeType=&quot;application/octet-stream&quot;)]
    private static const COLORIZE_CLASS:Class;
    private static const COLORIZE_SHADER:Shader = new Shader(new COLORIZE_CLASS());

    [Embed(source=&quot;../pbj/twirl.pbj&quot;, mimeType=&quot;application/octet-stream&quot;)]
    private static const TWIRL_CLASS:Class;
    private static const TWIRL_SHADER:Shader = new Shader(new TWIRL_CLASS());

    private function init():void
    {
        placeholder.addChild(bitmap);
    }

    private function mouseDownHandler(event:MouseEvent):void
    {
        drawing = true;
        color = Math.random() * 0xffffff;
    }

    private function initGraphics():void
    {
        container.graphics.clear();
        container.graphics.moveTo(mouseX, mouseY);
        container.graphics.lineStyle(10, color, 1);
    }

    private function mouseUpHandler(event:MouseEvent):void
    {
        drawing = false;
    }

    private function mouseMoveHandler(event:MouseEvent):void
    {
        if(!drawing)
            return;
        container.graphics.lineTo(event.localX, event.localY);
    }

    private function countFps():void
    {
        if(++fpsFrames &lt; 10)
            return;
        fps = Math.round(1 / (new Date().time - fpsDate.time) * 10000);
        fpsDate = new Date();
        fpsFrames = 0;
    }

    private function get w():Number
    {
        return container.width;
    }

    private function get h():Number
    {
        return container.height;
    }

    private function enterFrame():void
    {
        countFps();

        if(!container || !container.width)
            return;

        var bitmapData:BitmapData = new BitmapData(w, h, true, 0x000000);
        bitmapData.draw(bitmap);
        if(rotationCheckBox.selected)
            addRotation(bitmapData, 0.1);
        if(blurCheckBox.selected)
            addBlur(bitmapData);
        if(colorizeCheckBox.selected)
            addColorize(bitmapData, color);
        if(twirlCheckBox.selected)
        {
            var radius:Number = Math.min(w / 2, h / 2);
            addTwirl(bitmapData, 10, new Point(w / 4, h / 2), radius);
            addTwirl(bitmapData, -10, new Point(w / 4 * 3, h / 2), radius);
        }

        addAutoFill();
        bitmapData.draw(container);

        bitmap.bitmapData = bitmapData;
        initGraphics();
    }

    private function addAutoFill():void
    {
        lineX = (lineX &gt; w) ? 0 : (lineX + 15);
        container.graphics.moveTo(lineX - 15, h / 3 * 2);
        container.graphics.lineTo(lineX, h / 3 * 2);
    }

    private function addRotation(bitmapData:BitmapData, rotation:Number):void
    {
        rotationTime = new Date().time;
        ROTATION_SHADER.data.src.input = bitmapData;
        ROTATION_SHADER.data.src.width = w;
        ROTATION_SHADER.data.src.height = h;
        ROTATION_SHADER.data.rotation.value = [rotation];
        ROTATION_SHADER.data.tx.value = [w / 2];
        ROTATION_SHADER.data.ty.value = [h / 2];

        var job:ShaderJob = new ShaderJob(ROTATION_SHADER, bitmapData);
        job.start(true);
        rotationTime = new Date().time - rotationTime;
    }

    private function addBlur(bitmapData:BitmapData):void
    {
        blurTime = new Date().time;
        BLUR_SHADER.data.src.input = bitmapData;
        BLUR_SHADER.data.src.width = w;
        BLUR_SHADER.data.src.height = h;

        var job:ShaderJob = new ShaderJob(BLUR_SHADER, bitmapData);
        job.start(true);
        blurTime = new Date().time - blurTime;
    }

    private function addColorize(bitmapData:BitmapData, color:uint):void
    {
        colorizeTime = new Date().time;
        var r:Number = ((color &gt;&gt; 16) &amp; 0xFF) / 0xFF - 0.5;
        var g:Number = ((color &gt;&gt; <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_cool.gif' alt='8)' class='wp-smiley' /> &amp; 0xFF) / 0xFF - 0.5;
        var b:Number = (color &amp; 0xFF) / 0xFF - 0.5;

        COLORIZE_SHADER.data.src.input = bitmapData;
        COLORIZE_SHADER.data.src.width = w;
        COLORIZE_SHADER.data.src.height = h;
        COLORIZE_SHADER.data.color.value = [r / 40, g / 40, b / 40];

        var job:ShaderJob = new ShaderJob(COLORIZE_SHADER, bitmapData);
        job.start(true);
        colorizeTime = new Date().time - colorizeTime;
    }

    private function addTwirl(bitmapData:BitmapData, angle:Number,
        center:Point, radius:Number):void
    {
        twirlTime = new Date().time;
        TWIRL_SHADER.data.oImage.input = bitmapData;
        TWIRL_SHADER.data.oImage.width = w;
        TWIRL_SHADER.data.oImage.height = h;
        TWIRL_SHADER.data.radius.value = [radius];
        TWIRL_SHADER.data.center.value = [center.x, center.y];
        TWIRL_SHADER.data.twirlAngle.value = [angle];

        var job:ShaderJob = new ShaderJob(TWIRL_SHADER, bitmapData);
        job.start(true);
        twirlTime = new Date().time - twirlTime;
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:UIComponent width=&quot;100%&quot; height=&quot;100%&quot; id=&quot;placeholder&quot; /&gt;
&lt;mx:Container id=&quot;container&quot; width=&quot;100%&quot; height=&quot;100%&quot; backgroundAlpha=&quot;0&quot;/&gt;
&lt;mx:VBox paddingLeft=&quot;10&quot; paddingTop=&quot;10&quot;&gt;
    &lt;mx:Text text=&quot;fps: {fps} / 50&quot; /&gt;
    &lt;mx:HBox&gt;
        &lt;mx:CheckBox id=&quot;rotationCheckBox&quot; selected=&quot;true&quot;/&gt;
        &lt;mx:Label text=&quot;rotation {rotationTime} ms&quot; /&gt;
    &lt;/mx:HBox&gt;
    &lt;mx:HBox&gt;
        &lt;mx:CheckBox id=&quot;blurCheckBox&quot; selected=&quot;true&quot;/&gt;
        &lt;mx:Label text=&quot;blur {blurTime} ms&quot; /&gt;
    &lt;/mx:HBox&gt;
    &lt;mx:HBox&gt;
        &lt;mx:CheckBox id=&quot;colorizeCheckBox&quot; selected=&quot;true&quot;/&gt;
        &lt;mx:Label text=&quot;colorize {colorizeTime} ms&quot; /&gt;
    &lt;/mx:HBox&gt;
    &lt;mx:HBox&gt;
        &lt;mx:CheckBox id=&quot;twirlCheckBox&quot; selected=&quot;false&quot;/&gt;
        &lt;mx:Label text=&quot;twirl {twirlTime} ms&quot; /&gt;
    &lt;/mx:HBox&gt;
&lt;/mx:VBox&gt;
&lt;/mx:Application&gt;</pre>
<p>Rotation pixel bender</p>
<pre class="brush: xml;">&lt;languageVersion : 1.0;&gt;

kernel RotationFilter
&lt;
	namespace : &quot;sk.yoz&quot;;
	vendor : &quot;Yoz&quot;;
	version : 1;
	description : &quot;Image rotation over transform point&quot;;
&gt;
{
	input image4 src;
	output pixel4 dst;

	parameter float tx
	&lt;
		minValue: float(0.0);
		maxValue: float(4096.0);
		defaultValue: float(0.0);
		description: &quot;The amount of movement along the x axis to the right, in pixels.&quot;;
	&gt;;

	parameter float ty
	&lt;
		minValue: float(0.0);
		maxValue: float(4096.0);
		defaultValue: float(0.0);
		description: &quot;The amount of movement down along the y axis, in pixels.&quot;;
	&gt;;

	parameter float rotation
	&lt;
		minValue: float(0.0);
		maxValue: float(4096.0);
		defaultValue: float(0.0);
		description: &quot;Rotation in radians&quot;;
	&gt;;

	void evaluatePixel()
	{
		float2 pos = outCoord();
		float rc = cos(rotation);
		float rs = sin(rotation);
		float dx = pos.x - tx;
		float dy = pos.y - ty;
		dst = sampleNearest(src, float2(
			tx + rc * dx + rs * dy,
			ty + rc * dy - rs * dx));
	}
}</pre>
<p>Blur pixel bender</p>
<pre class="brush: xml;">&lt;languageVersion : 1.0;&gt;

kernel BlurFilter
&lt;
	namespace : &quot;sk.yoz&quot;;
	vendor : &quot;Yoz&quot;;
	version : 1;
	description : &quot;Simple blur&quot;;
&gt;
{
	input image4 src;
	output pixel4 dst;

	void evaluatePixel()
	{
		float2 pos = outCoord();

		dst = 1.0 / 9.0 * (
			sampleNearest(src, pos - float2(-1.0, -1.0))
			+ sampleNearest(src, pos - float2(0.0, -1.0))
			+ sampleNearest(src, pos - float2(1.0, -1.0))
			+ sampleNearest(src, pos - float2(-1.0, 0.0))
			+ sampleNearest(src, pos - float2(0.0, 0.0))
			+ sampleNearest(src, pos - float2(1.0, 0.0))
			+ sampleNearest(src, pos - float2(-1.0, 1.0))
			+ sampleNearest(src, pos - float2(0.0, 1.0))
			+ sampleNearest(src, pos - float2(1.0, 1.0)));
	}
}</pre>
<p>Colorize pixel bender</p>
<pre class="brush: xml;">&lt;languageVersion : 1.0;&gt;

kernel ColorizeFilter
&lt;
	namespace : &quot;sk.yoz&quot;;
	vendor : &quot;Yoz&quot;;
	version : 1;
	description : &quot;Simple colorize&quot;;
&gt;
{
	input image4 src;
	output pixel4 dst;

	parameter float3 color
	&lt;
		minValue: float3(-1.0, -1.0, -1.0);
		maxValue: float3(1.0, 1.0, 1.0);
		defaultValue: float3(0.0, 0.0, 0.0);
		description: &quot;Color&quot;;
	&gt;;

	void evaluatePixel()
	{
		dst = sampleNearest(src, outCoord());
		dst.r += color.r;
		dst.g += color.g;
		dst.b += color.b;
	}
}</pre>
<p><a href="http://www.adobe.com/cfusion/exchange/index.cfm?event=extensionDetail&#038;extid=1536021">Twirl pixel bender effect is available for download here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/pixel-bender-disco/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inline Images</title>
		<link>http://blog.yoz.sk/2010/02/inline-images/</link>
		<comments>http://blog.yoz.sk/2010/02/inline-images/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 14:59:44 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[Bitmap]]></category>
		<category><![CDATA[ByteArray]]></category>
		<category><![CDATA[ExternalInterface]]></category>
		<category><![CDATA[PNGEncoder]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1106</guid>
		<description><![CDATA[
Have you ever heard about inline images? Inline images use the data URI scheme to embed images directly within web pages. As defined by RFC 2397, data URIs are designed to embed small data items as &#8220;immediate&#8221; data, as if they were referenced externally. This basicaly means, you can insert base64 encoded byte code of [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/inlineImage-200x122.png" alt="" title="inlineImage" width="200" height="122" class="alignleft size-medium wp-image-1111" /></p>
<p>Have you ever heard about <a href="http://www.websiteoptimization.com/speed/tweak/inline-images/">inline images</a>? Inline images use the data URI scheme to embed images directly within web pages. As defined by RFC 2397, data URIs are designed to embed small data items as &#8220;immediate&#8221; data, as if they were referenced externally. This basicaly means, you can insert base64 encoded byte code of any image directly into html file. Using inline images saves HTTP requests over externally referenced objects. Data URIs can potentially <a href="http://www.greywyvern.com/code/php/binary2base64">store any type of data</a>, not just images!</p>
<p><span id="more-1106"></span></p>
<p>This example creates snapshot of flash application (on left side) and dynamicly (using javascript) creates inline image (right side) with base64 encoded bytes in src attribute. (right side is html &lt;img&gt;)</p>
<p><iframe width="100%" height="300" style="border:none;" src="http://blog.yoz.sk/examples/inlineImages/"></iframe></p>
<p>Application source:</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot; layout=&quot;vertical&quot;
    enterFrame=&quot;enterFrame()&quot; borderStyle=&quot;solid&quot; borderColor=&quot;#000000&quot;
    backgroundColor=&quot;#ffffff&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import com.adobe.images.PNGEncoder;
    import com.dynamicflash.util.Base64;

    private function enterFrame():void
    {
        if(!container || !container.width)
            return;

        container.graphics.beginFill(Math.random() * 0xffffff, Math.random());
        container.graphics.drawCircle(
            Math.random() * container.width,
            Math.random() * container.height, Math.random() * 30);

    }

    private function makeSnapshot(source:DisplayObject):void
    {
        var script:String = 'var img = document.getElementById(&quot;img&quot;);'
            + 'if(!img)'
            + '{'
                + 'img = document.createElement(&quot;IMG&quot;);'
                + 'img.id=&quot;img&quot;;'
                + 'document.body.appendChild(img);'
            + '}'
            + 'img.src=&quot;' + getSrc(source) +'&quot;;';
        ExternalInterface.call(&quot;function(){&quot; + script + &quot;}&quot;);
    }

    private function getByteArray(source:DisplayObject):ByteArray
    {
        var bitmapData:BitmapData = new BitmapData(source.width, source.height);
        bitmapData.draw(source);
        var bitmap:Bitmap = new Bitmap(bitmapData);
        return PNGEncoder.encode(bitmapData);
    }

    private function getSrc(source:DisplayObject):String
    {
        var byteArray:ByteArray = getByteArray(source);
        return 'data:image/png;base64,'
            + Base64.encodeByteArray(byteArray);
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Container id=&quot;container&quot; width=&quot;100%&quot; height=&quot;100%&quot;/&gt;
&lt;mx:Button label=&quot;Make Snapshot&quot; click=&quot;makeSnapshot(this)&quot;/&gt;
&lt;/mx:Application&gt;</pre>
<p>Data URLs save HTTP requests. When combined with CSS sprites, data URLs can save numerous HTTP requests. It would be interesting to see if data URLs can be combined with USEMAPS or make a data URL CSS sprite. Data URLs are a convenient way to create self-enclosed web pages that don&#8217;t rely on external objects to render.</p>
<ul>
<li>Save HTTP requests, avoids adding to object overhead</li>
<li>Save concurrent thread &#8211; browsers default to two simultaneous connections per hostname</li>
<li>HTTPS requests are simplified and performance improved</li>
</ul>
<p>Well, for now I have no idea how can flash benefit from data urls <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  but if I come to something I let you know.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/inline-images/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Processing Audio in ActionScript 3 and Pixel Bender</title>
		<link>http://blog.yoz.sk/2010/02/processing-audio-in-actionscript-3-and-pixel-bender/</link>
		<comments>http://blog.yoz.sk/2010/02/processing-audio-in-actionscript-3-and-pixel-bender/#comments</comments>
		<pubDate>Tue, 16 Feb 2010 11:52:48 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Audio]]></category>
		<category><![CDATA[effects]]></category>
		<category><![CDATA[equalizer]]></category>
		<category><![CDATA[pixel bender]]></category>
		<category><![CDATA[Sound]]></category>
		<category><![CDATA[spectrum]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1090</guid>
		<description><![CDATA[
Recently I was trying to make some noise with flash, and soon I realized that audio processing is not that easy thing as it may look like. Anyway here is a list of some interesting articles and examples with gain, equalizer, pitch, effects, pixel bender, I have came across while gathering information.

Volume, Equalizer, Effects, Pitch

Volume [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/spectrumAnalyzer1.png" alt="" title="spectrumAnalyzer" width="200" height="100" class="alignleft size-full wp-image-1100" /></p>
<p>Recently I was trying to <a href="http://www.google.cz/search?hl=cs&#038;rlz=1C1GGLS_csCZ334CZ334&#038;q=make+some+noise+adobe&#038;btnG=Hledat&#038;lr=&#038;aq=f&#038;oq=">make some noise</a> with flash, and soon I realized that audio processing is not that easy thing as it may look like. Anyway here is a list of some interesting articles and examples with gain, equalizer, pitch, effects, pixel bender, I have came across while gathering information.</p>
<p><span id="more-1090"></span></p>
<h3 style="clear:both;">Volume, Equalizer, Effects, Pitch</h3>
<ul>
<li><a href="http://blogs.adobe.com/kevin.goldsmith/2009/08/pixel_bender_au.html">Volume change using Pixel Bender + source</a></li>
<li><a href="http://www.kaourantin.net/2008/10/audio-mixing-with-pixel-bender.html">Multiple audio mixing with Pixel Bender + source</a></li>
<li><a href="http://ciboloweb.com/website-resources/website-design-articles/2009/08/flex-soundgraphic-equalizer-5-band/">5 band equalizer by Cibolo Media Services + source</a></li>
<li><a href="http://lab.andre-michelle.com/eq-filter">3 band equalizer by Andre Michelle</a></li>
<li><a href="http://www.blixtsystems.com/2008/05/simple-3-band-eq-with-flash-player-10/">3 band equalizer BlixtSystems + source</a></li>
<li><a href="http://www.anttikupila.com/flash/soundfx-out-of-the-box-audio-filters-with-actionscript-3/">echo, phase, feedback, cutoff, resonance by Antti Kupila + source</a></li>
<li><a href="http://www.akaneko.com/yanetzel/?p=221">Distorsion using Pixel Bender by Akaneko + source</a></li>
<li><a href="http://theflashblog.com/?p=1129">Audio pitch by Lee Brimelow + source</a></li>
</ul>
<h3>Spectrum Analyzer</h3>
<ul>
<li><a href="http://www.everydayflash.com/blog/index.php/2008/03/26/classic-sound-equalizer-in-flashas3/">Classic spectrum analyer</a></li>
<li><a href="http://theflashblog.com/?p=197">ActionScript 3 Sound Spectrum Contest Results</a></li>
</ul>
<h3>Theory and Hints</h3>
<ul>
<li><a href="http://stackoverflow.com/questions/1099103/create-a-flash-equalizer-modify-output-sound">Equalizer</a></li>
<li><a href="http://www.sasarudan.com/en/technologyblog/flashadobe/4-flash10audio.html">Fast Fourier Transform</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/processing-audio-in-actionscript-3-and-pixel-bender/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick tip: ExternalInterface.call is synchronous!</title>
		<link>http://blog.yoz.sk/2010/02/quick-tip-externalinterface-call-is-synchronous/</link>
		<comments>http://blog.yoz.sk/2010/02/quick-tip-externalinterface-call-is-synchronous/#comments</comments>
		<pubDate>Fri, 12 Feb 2010 16:21:01 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[ExternalInterface]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1067</guid>
		<description><![CDATA[
It is a little wonder to me how flash player communicates with JavaScript. Calls are fully synchronous, it works as those (fp and js) were fully integrated into each other. To simulate this lets test some simple flow:


Flash Player calls JavaScript
    JavaScript calls FlashPlayer
        FlashPlayer [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/synchronous.jpg" alt="" title="synchronous" width="200" height="100" class="alignleft size-full wp-image-1081" /></p>
<p>It is a little wonder to me how flash player communicates with JavaScript. Calls are fully synchronous, it works as those (fp and js) were fully integrated into each other. To simulate this lets test some simple flow:</p>
<p><span id="more-1067"></span></p>
<div style="clear:both;"></div>
<pre class="brush: plain;">Flash Player calls JavaScript
    JavaScript calls FlashPlayer
        FlashPlayer do some stuff and finishes
    JavaScript finishes
FlashPlayer continues</pre>
<p>Following flex application runs simple JavaScript:</p>
<pre class="brush: jscript;">document.getElementById(&quot;flash&quot;).universalCallback();
return &quot;synchronous return&quot;;</pre>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    applicationComplete=&quot;init()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    [Bindable]
    private var lastResult:String = &quot;&quot;;

    private function init():void
    {
        ExternalInterface.addCallback(&quot;universalCallback&quot;, universalCallback);
    }

    private function runScript():void
    {
        var script:String = 'document.getElementById(&quot;flash&quot;).universalCallback();' +
                'return &quot;synchronous return&quot;;';

        var result:String = ExternalInterface.call(&quot;function(){&quot; + script + &quot;}&quot;);
        lastResult += result + &quot;\n&quot;;
    }

    private function universalCallback(... rest):void
    {
        lastResult += &quot;universalCallback&quot; + &quot;\n&quot;;
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Button click=&quot;runScript()&quot; label=&quot;Run&quot;/&gt;
&lt;mx:TextArea width=&quot;100%&quot; height=&quot;100%&quot; text=&quot;{lastResult}&quot; /&gt;
&lt;/mx:Application&gt;</pre>
<p>and results are logged into TextArea:</p>
<pre class="brush: plain;">universalCallback
synchronous return</pre>
<p>This means that ExternalInterface.call() is synchronous and waits until called JavaScript finishes. Just after that, flash player moves on the next line. This interesting behaviour makes flash player to hold (but not to freeze) on one line while it is able to continue on different execution (universalCallback()). </p>
<p>Notice, JavaScript to ActionScript data can be sent via ExternalInterface.addCallback() or simple by synchronous return:</p>
<pre class="brush: as3;">var result:String = ExternalInterface.call(&quot;function(){&quot; + script + &quot;}&quot;);</pre>
<p>however, you can not use eval method this way!</p>
<pre class="brush: as3;">var result:String = ExternalInterface.call(&quot;eval&quot;, script);</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/quick-tip-externalinterface-call-is-synchronous/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Full JavaScript Access From ActionScript (update)</title>
		<link>http://blog.yoz.sk/2010/02/full-javascript-access-from-actionscript/</link>
		<comments>http://blog.yoz.sk/2010/02/full-javascript-access-from-actionscript/#comments</comments>
		<pubDate>Wed, 10 Feb 2010 10:10:55 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[allowscriptaccess]]></category>
		<category><![CDATA[eval]]></category>
		<category><![CDATA[ExternalInterface]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1005</guid>
		<description><![CDATA[
Have you ever tought about accessing DOM from ActionScript? In fact, you can do it and even far more. You can create and call JavaScript methods and objects, access cookies, change styles&#8230; All you need is correct AllowScriptAccess parameter within your flash object. No framework needed here, no hacks, ExternalInterface takes care.

Following application runs JavaScript [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/fullJavascriptAccess.png" alt="" title="fullJavascriptAccess" width="200" height="100" class="alignleft size-full wp-image-1047" /></p>
<p>Have you ever tought about accessing <a href="http://cs.wikipedia.org/wiki/Document_Object_Model">DOM</a> from ActionScript? In fact, you can do it and even far more. You can create and call JavaScript methods and objects, access cookies, change styles&#8230; All you need is correct <a href="http://kb2.adobe.com/cps/164/tn_16494.html">AllowScriptAccess</a> parameter within your flash object. No framework needed here, no hacks, ExternalInterface takes care.</p>
<p><span id="more-1005"></span></p>
<p style="clear:both;">Following application runs JavaScript from textarea:</p>
<p><iframe width="100%" height="300" style="border:none;" src="http://blog.yoz.sk/examples/fullJavascriptAccess/"></iframe></p>
<p>Application. Line 16 does all the fun <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    applicationComplete=&quot;init()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    [Bindable]
    private var lastResult:String = &quot;&quot;;

    private function init():void
    {
        ExternalInterface.addCallback(&quot;universalCallback&quot;, universalCallback);
    }

    private function runScript():void
    {
        ExternalInterface.call(&quot;eval&quot;, script.text);
    }

    private function universalCallback(... rest):void
    {
        lastResult = String(rest[0]);
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:HBox width=&quot;100%&quot; height=&quot;100%&quot;&gt;
    &lt;mx:TextArea id=&quot;script&quot; width=&quot;100%&quot; height=&quot;100%&quot;&gt;
        &lt;mx:text&gt;
            &lt;![CDATA[
function myFunction(){
    var flash = document.getElementById(&quot;flash&quot;);
    var data = document.childNodes[1].innerHTML;
    flash.universalCallback(data);
}

myFunction();
alert(document.getElementsByTagName('title')[0].innerHTML);
            ]]&gt;
        &lt;/mx:text&gt;
    &lt;/mx:TextArea&gt;
    &lt;mx:TextArea width=&quot;100%&quot; height=&quot;100%&quot; text=&quot;{lastResult}&quot; /&gt;
&lt;/mx:HBox&gt;

&lt;mx:Button click=&quot;runScript()&quot; label=&quot;Run&quot;/&gt;
&lt;/mx:Application&gt;</pre>
<p>HTML template</p>
<pre class="brush: xml;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
&lt;head&gt;
    &lt;title&gt;Full Javascript Access&lt;/title&gt;
    &lt;meta http-equiv=&quot;Content-Type&quot; content=&quot;application/xml; charset=utf-8&quot; /&gt;
    &lt;meta http-equiv=&quot;Cache-Control&quot; content=&quot;no-cache&quot; /&gt;
    &lt;meta http-equiv=&quot;expires&quot; content=&quot;1&quot; /&gt;
    &lt;meta http-equiv=&quot;pragma&quot; content=&quot;no-cache&quot; /&gt; 

    &lt;meta name=&quot;author&quot; content=&quot;http://studio.yoz.sk&quot; /&gt;
    &lt;meta name=&quot;description&quot; content=&quot;Full Javascript Access&quot; /&gt;
    &lt;meta name=&quot;robots&quot; content=&quot;all&quot; /&gt; 

    &lt;script type=&quot;text/javascript&quot; src=&quot;js/swfobject.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    &lt;!--
        var flashvars = {}

        var params = {
            allowscriptaccess: &quot;always&quot;
        };
        var attributes = {
            id: &quot;flash&quot;,
            name: &quot;flash&quot;
        };
        swfobject.embedSWF(&quot;Tests.swf&quot;, &quot;alternative&quot;, &quot;100%&quot;, &quot;100%&quot;, &quot;10.0.0&quot;,
            &quot;flash/expressInstall.swf&quot;, flashvars, params, attributes);
    //--&gt;
    &lt;/script&gt;

    &lt;style type='text/css'&gt;
    &lt;!--
        body {margin:0px;overflow:hidden;}
        html, body, object, embed {width:100%;height:100%;outline:none;}
    --&gt;
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;alternative&quot;&gt;
        &lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
            &lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;
        &lt;/a&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>No additional nothing here just:</p>
<ul>
<li>line 20: allowscriptaccess: &#8220;always&#8221; (&#8220;sameDomain&#8221; may also be used)</li>
<li>line 24: tip &#8211; add name attribute with swfobject so ExternalInterface.objectID will get correct value</li>
</ul>
<p><a href="http://stackoverflow.com/questions/86513/why-is-using-javascript-eval-function-a-bad-idea">Considerations of using eval</a>:</p>
<ul>
<li>Improper use of eval opens up your code for injection attacks</li>
<li>Debugging can be more challenging (no line numbers, etc.)</li>
<li>eval&#8217;d code executes more slowly (no opportunity to compile/cache eval&#8217;d code)</li>
</ul>
<p>Update (Feb 11, 2010): You can use either eval call:</p>
<pre class="brush: as3;">ExternalInterface.call(&quot;eval&quot;, script.text);</pre>
<p>or wrap your script into anonymous function:</p>
<pre class="brush: as3;">ExternalInterface.call(&quot;function(){&quot; + script.text + &quot;}&quot;);</pre>
<p>Personally, I do not see any difference in execution, it seems to be the same, maybe some performance testing would clarify it. What do you think?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/full-javascript-access-from-actionscript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>onConference &#8211; video chat over facebook</title>
		<link>http://blog.yoz.sk/2010/02/onconference-video-chat-over-facebook/</link>
		<comments>http://blog.yoz.sk/2010/02/onconference-video-chat-over-facebook/#comments</comments>
		<pubDate>Tue, 09 Feb 2010 09:28:08 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[Projects]]></category>
		<category><![CDATA[chat]]></category>
		<category><![CDATA[onConference]]></category>
		<category><![CDATA[video]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1022</guid>
		<description><![CDATA[
onConference is flash application allowing individuals &#38; businesses to meet face-to-face. Keep in touch with your friends, family and business associates via onConference chat or live video chat.
To be more specific, onConference is using RTMFP protocol, so your conferences, even those multiuser are p2p. Yes, any conference can join multiple users. I decided to use [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/onconference-200x132.jpg" alt="" title="onconference" width="200" height="132" class="alignleft size-medium wp-image-1023" /></p>
<p><a href="http://apps.facebook.com/onconference/">onConference</a> is flash application allowing individuals &amp; businesses to meet face-to-face. Keep in touch with your friends, family and business associates via onConference chat or live video chat.</p>
<p>To be more specific, onConference is using RTMFP protocol, so your conferences, even those multiuser are p2p. Yes, any conference can join multiple users. I decided to use simpliest look-n-feel á la facebook and no pageflow, so you get connected immediately&#8230; You can find <a href="http://apps.facebook.com/onconference/">onConference on http://apps.facebook.com/onconference/</a>, please let me know if you like it, any feedback welcomed <img src='http://blog.yoz.sk/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  .</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/onconference-video-chat-over-facebook/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>TextInput wmode opaque/tranpsarent workaround</title>
		<link>http://blog.yoz.sk/2010/02/textinput-wmode-opaque-transparent-workaround/</link>
		<comments>http://blog.yoz.sk/2010/02/textinput-wmode-opaque-transparent-workaround/#comments</comments>
		<pubDate>Mon, 08 Feb 2010 10:27:56 +0000</pubDate>
		<dc:creator>Jozef Chúťka</dc:creator>
				<category><![CDATA[ActionScript]]></category>
		<category><![CDATA[Flash / Flex]]></category>
		<category><![CDATA[allowscriptaccess]]></category>
		<category><![CDATA[FlexIFrame]]></category>
		<category><![CDATA[input]]></category>
		<category><![CDATA[opaque]]></category>
		<category><![CDATA[text]]></category>
		<category><![CDATA[transparent]]></category>
		<category><![CDATA[wmode]]></category>

		<guid isPermaLink="false">http://blog.yoz.sk/?p=1004</guid>
		<description><![CDATA[
Many of you have come accross the horrendous bug that happens with text input in flash when the swf is embedded with wmode=transparent/opaque. It has been much discussed (Firefox Bugzilla entry for this bug, Adobe Forum discussion, etc.), but it seems that in all the years that this bug has existed nothing much has been [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.yoz.sk/wp-content/uploads/fakeTextInput-200x100.png" alt="" title="fakeTextInput" width="200" height="100" class="alignleft size-medium wp-image-1015" /></p>
<p>Many of you have come accross the horrendous bug that happens with text input in flash when the swf is embedded with wmode=transparent/opaque. It has been much discussed (<a href="https://bugzilla.mozilla.org/show_bug.cgi?id=347185">Firefox Bugzilla entry for this bug</a>, <a href="http://bugs.adobe.com/jira/browse/FP-479">Adobe Forum discussion</a>, etc.), but it seems that in all the years that this bug has existed nothing much has been done. A <a href="http://www.google.cz/search?hl=cs&#038;rlz=1C1GGLS_csCZ334CZ334&#038;q=wmode+transparent+text+input+workaround&#038;btnG=Hledat&#038;lr=&#038;aq=f&#038;oq=">lot of workarounds have been published</a>, many of them based on custom key mapping etc&#8230; My workaround uses html element &lt;input type=&#8221;text&#8221;&gt; that is placed right over flex &lt;mx:TextInput&gt;. Html element is styled transparent (no design) so user will not notice.</p>
<p><span id="more-1004"></span></p>
<p>Following application uses wmode &#8220;opaque&#8221;, try inserting characters (čšň) into first text input (mx:TextInput) and than into second (uses html &lt;input type=&#8221;text&#8221;&gt; over flash)</p>
<p><iframe width="100%" height="300" src="http://blog.yoz.sk/examples/fakeTextInput/"></iframe></p>
<p>Main application</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:Application xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    applicationComplete=&quot;init()&quot; viewSourceURL=&quot;srcview/index.html&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    import mx.managers.PopUpManager;
    private function init():void
    {
        var window:FakeInputsWindow = new FakeInputsWindow();
        PopUpManager.addPopUp(window, this);
        PopUpManager.centerPopUp(window);
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;/mx:Application&gt;</pre>
<p>FakeInputsWindow</p>
<pre class="brush: xml;">&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
&lt;mx:TitleWindow
    xmlns:mx=&quot;http://www.adobe.com/2006/mxml&quot;
    xmlns:html=&quot;sk.yoz.html.*&quot;
    layout=&quot;vertical&quot; width=&quot;400&quot; height=&quot;250&quot;
    creationComplete=&quot;init()&quot;
    move=&quot;moveHandler()&quot;&gt;
&lt;mx:Script&gt;
&lt;![CDATA[
    [Bindable]
    private var text2:String = &quot;&quot;;

    private function init():void
    {
        ExternalInterface.addCallback(&quot;fakeTextInputChange&quot;, fakeTextChange);
    }

    private function moveHandler():void
    {
        fakeTextInput.positionChanged = true;
        fakeTextInput.invalidateProperties();
    }

    private function fakeTextChange(value:String):void
    {
        text2 = value;
    }
]]&gt;
&lt;/mx:Script&gt;
&lt;mx:Text text='&amp;lt;mx:TextInput ....'/&gt;
&lt;mx:TextInput id=&quot;text1&quot; width=&quot;300&quot; height=&quot;20&quot;/&gt;
&lt;mx:Label text=&quot;{text1.text}&quot; /&gt;
&lt;mx:Spacer height=&quot;10&quot; /&gt;
&lt;mx:Text text='&amp;lt;input type=&quot;text&quot; ....'/&gt;
&lt;mx:Canvas width=&quot;300&quot; height=&quot;20&quot;&gt;
    &lt;mx:TextInput width=&quot;300&quot; height=&quot;20&quot;/&gt;
    &lt;html:IFrame width=&quot;100%&quot; height=&quot;100%&quot; id=&quot;fakeTextInput&quot;
        autoResize=&quot;true&quot;/&gt;
&lt;/mx:Canvas&gt;
&lt;mx:Label text=&quot;{text2}&quot; /&gt;
&lt;/mx:TitleWindow&gt;</pre>
<p>lines:</p>
<ul>
<li>15: javascript-to-flash callback definition fakeTextInputChange (from javascript) sends value into actionscript fakeTextChange()</li>
<li>18: fakeTextInput is IFrame class, that controls position and size of html input, lets correct position on TitleWindow move&#8230;</li>
<li>35-39: I placed IFrame over TextInput. IFrame is in fact transparent html input, so what user see is just flex TextInput graphics</li>
</ul>
<p>Html template file</p>
<pre class="brush: xml;">&lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd&quot;&gt;
&lt;html xmlns=&quot;http://www.w3.org/1999/xhtml&quot; xml:lang=&quot;en&quot; lang=&quot;en&quot; dir=&quot;ltr&quot;&gt;
&lt;head&gt;
    &lt;title&gt;FakeTextInput&lt;/title&gt;
    ...
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/swfobject.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;js/flexiframe.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
    &lt;!--
        var flashvars = {}

        var params = {
            allowscriptaccess: &quot;always&quot;,
            wmode: &quot;opaque&quot;
        };
        var attributes = {
            id: &quot;flash&quot;
        };
        swfobject.embedSWF(&quot;Tests.swf&quot;, &quot;alternative&quot;, &quot;100%&quot;, &quot;100%&quot;, &quot;10.0.0&quot;,
            &quot;flash/expressInstall.swf&quot;, flashvars, params, attributes);

        function fakeTextInputChange()
        {
            var input = document.getElementById('fakeTextInput');
            var flash = document.getElementById('flash');
            flash.fakeTextInputChange(input.value);
        }
    //--&gt;
    &lt;/script&gt; 

    &lt;style type='text/css'&gt;
    &lt;!--
        body {margin:0px;overflow:hidden;}
        html, body, object, embed {width:100%;height:100%;outline:none;}
        #fakeTextInput {
            position:absolute;
            border:none;
            outline:none;
            padding:0;
            margin:0;
            background:transparent url(&quot;images/spacer.gif&quot;);
            vertical-align:middle;
        }
    --&gt;
    &lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;
    &lt;div id=&quot;alternative&quot;&gt;
        &lt;a href=&quot;http://www.adobe.com/go/getflashplayer&quot;&gt;
            &lt;img src=&quot;http://www.adobe.com/images/shared/download_buttons/get_flash_player.gif&quot; alt=&quot;Get Adobe Flash player&quot; /&gt;
        &lt;/a&gt;
    &lt;/div&gt;
    &lt;input type=&quot;text&quot; id=&quot;fakeTextInput&quot; onkeyup=&quot;fakeTextInputChange()&quot;/&gt;
&lt;/body&gt;
&lt;/html&gt;</pre>
<p>Notice lines:</p>
<ul>
<li>07: import <a href="http://blog.yoz.sk/2009/10/flex-iframe-web-browser-in-flash/">flexiframe.js</a> used for positioning html input on correct place</li>
<li>13: allowscriptaccess must be enabled</li>
<li>14: wmode opaque/transparent is what the source of all evil</li>
<li>22: javascript-to-flash communication</li>
<li>35-42: remove all html input text design and makes it transparent</li>
<li>53: input text definition, you may want to define your own handlers (submit, paste, focus&#8230;)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.yoz.sk/2010/02/textinput-wmode-opaque-transparent-workaround/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
