<?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>JActionScripters</title>
	<atom:link href="http://blog.jactionscripters.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.jactionscripters.com</link>
	<description>More than 20 Japanese flash coders share the blog/ You will be junkie for this crazy Japanese Flash news</description>
	<lastBuildDate>Sat, 08 Oct 2011 16:55:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Flash Player 11 adds new methods of the Matrix3D class to copy elements</title>
		<link>http://blog.jactionscripters.com/2011/10/09/flash-player-11-adds-new-methods-of-the-matrix3d-class-to-copy-elements/</link>
		<comments>http://blog.jactionscripters.com/2011/10/09/flash-player-11-adds-new-methods-of-the-matrix3d-class-to-copy-elements/#comments</comments>
		<pubDate>Sat, 08 Oct 2011 16:55:34 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1544</guid>
		<description><![CDATA[Flash Player 11 and AIR 3.0 adds new methods of the Matrix3D class to copy elements between a Matrix3D object and Matrix3D, Vector3D or Vector objects.  A Matrix3D object represents a square matrix of order 4 to transform coordinates in 3D.[*1]
The four methods in the table below copy elements of a row or column [...]]]></description>
			<content:encoded><![CDATA[<p>Flash Player 11 and AIR 3.0 adds new methods of the Matrix3D class to copy elements between a Matrix3D object and Matrix3D, Vector3D or Vector objects.  A Matrix3D object represents a <a href="http://en.wikipedia.org/wiki/Square_matrix#Square_matrices" target="_blank">square matrix</a> of order 4 to transform coordinates in 3D.<sup>[*1]</sup></p>
<div id="attachment_1547" class="wp-caption alignnone" style="width: 310px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2011/10/Matrix3Delements-e.gif" alt="Representation of Matrix3D elements" title="Representation of Matrix3D elements" width="300" height="200" class="alignnone size-full wp-image-1547" /><p class="wp-caption-text">A Matrix3D object represents a square matrix of order 4.</p></div>
<p>The four methods in the table below copy elements of a row or column between the referenced Matrix3D ooject and the Vector3D object of its argument.</p>
<table border="1" cellspacing="0" bordercolor="#9999FF">
<tr>
<td bgcolor="#CCCCFF">
<strong>Target</strong>
</td>
<td bgcolor="#CCCCFF">
      <strong>Method of Matrix3D class</strong>
</td>
<td bgcolor="#CCCCFF">
      <strong>Direction</strong>
</td>
</tr>
<tr>
<td rowspan="2" align="center" bgcolor="#EEEEFF">
Column
</td>
<td bgcolor="#EEEEFF">
<strong>copyColumnFrom()</strong>
</td>
<td>
Vector3D -> Matrix3D
</td>
</tr>
<tr>
<td bgcolor="#EEEEFF">
  <strong>copyColumnTo()</strong>
</td>
<td>
Matrix3D -> Vector3D
</td>
</tr>
<tr>
<td rowspan="2" align="center" bgcolor="#EEEEFF">
Row
</td>
<td bgcolor="#EEEEFF">
<strong>copyRowFrom()</strong>
</td>
<td>
Vector3D -> Matrix3D
</td>
</tr>
<tr>
<td bgcolor="#EEEEFF">
  <strong>copyRowTo()</strong>
</td>
<td>
Matrix3D -> Vector3D
</td>
</tr>
</table>
<p><a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix3D.html#rawData" target="_blank"><em>Matrix3D.rawData</em> property</a> reads or writes 16 elements of a Matrix3D object, which are stored in a Vector object with Number base type.  The two methods in the table below can copy all 16 elements between the referenced Matrix3D object and the Vector object of its argument.  A Vector object of the Matrix3D.rawData property stores elements of a matrix column-by-column.<sup>[*2]</sup></p>
<table border="1" cellspacing="0" bordercolor="#9999FF">
<tr>
<td bgcolor="#CCCCFF">
    <strong>Method of Matrix3D class</strong>
</td>
<td bgcolor="#CCCCFF">
      <strong>Direction</strong>
</td>
</tr>
<tr>
<td bgcolor="#EEEEFF">
  <strong>copyRawDataFrom()</strong>
</td>
<td>
Vector -> Matrix3D
</td>
</tr>
<tr>
<td bgcolor="#EEEEFF">
  <strong>copyRawDataTo()</strong>
</td>
<td>
Matrix3D -> Vector
</td>
</tr>
</table>
<p>The <em>Matrix3D.copyFrom()</em> method copies elements between the referenced Matrix3D object and the other one of it argument.  It does not create new Matrix3D object unlike the Matrix3D.clone() method.  As it can use existing Matrix3D object, it consume less memory and can avoid the garbage collection.</p>
<hr />
<p>[*1] [<a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/Matrix3D.html" target="_blank">Matrix3D</a>] of the [Help] shows the figure below with the following description:</p>
<blockquote>
<p>The Matrix3D class uses a 4&#215;4 square matrix: a table of four rows and columns of numbers that hold the data for the transformation. The first three rows of the matrix hold data for each 3D axis (x,y,z). The translation information is in the last column. The orientation and scaling data are in the first three columns. The scaling factors are the diagonal numbers in the first three columns. Here is a representation of Matrix3D elements:</p>
<p><img src="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/images/Matrix3Delements.jpg" alt="Representation of Matrix3D elements in the Help" title="Representation of Matrix3D elements in the Help" width="300" height="246" class="alignnone size-full wp-image-1547" /></p></blockquote>
<p>But the positions of &#8220;x-axis&#8221;, &#8220;y-axis&#8221; and &#8220;z-axis&#8221; are not match to the statement that &#8220;The <strong>first three rows</strong> of the matrix hold data for each 3D axis (x,y,z)&#8221;.  Therefore, the figure inserted in the body text is modified to place them to the correct positions.</p>
<p>[*2] The [Help] describes a Vector object of the Matrix3D.rawData as follows:</p>
<blockquote><p>A Vector of 16 Numbers, where every four elements can be a row or a column of a 4&#215;4 matrix.</p></blockquote>
<p>However every four elements is a COLUMN of a 4&#215;4 matrix as described in the body text.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2011/10/09/flash-player-11-adds-new-methods-of-the-matrix3d-class-to-copy-elements/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Calculating coordinates to rotate</title>
		<link>http://blog.jactionscripters.com/2011/09/22/calculating-coordinates-to-rotate/</link>
		<comments>http://blog.jactionscripters.com/2011/09/22/calculating-coordinates-to-rotate/#comments</comments>
		<pubDate>Thu, 22 Sep 2011 05:42:19 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1479</guid>
		<description><![CDATA[There are two formulas to calculate coordinates (x, y) with trigonometric functions by specifying angle ø.  The first is &#8220;polar coordinates&#8221; defined with a radius, distance r from the origin (0, 0), and an angle ø between the x axis.
[1] polar: radius r from the origin (0, 0) and angle ø between the x [...]]]></description>
			<content:encoded><![CDATA[<p>There are two formulas to calculate coordinates (x, y) with trigonometric functions by specifying angle ø.  The first is &#8220;polar coordinates&#8221; defined with a radius, distance r from the origin (0, 0), and an angle ø between the x axis.</p>
<p>[1] polar: radius r from the origin (0, 0) and angle ø between the x axis.</p>
<blockquote><p>x: r cosø<br />
y: r sinø</p></blockquote>
</ul>
<p><img src="http://blog.jactionscripters.com/wp-content/uploads/2011/09/ActionScript30for3D_M01_006.gif" alt="ActionScript30for3D_M01_006" title="ActionScript30for3D_M01_006" width="236" height="239" class="alignnone size-full wp-image-1482" /></p>
<p>The following code places a MovieClip instance <em>my_mc</em> at the point of which the radius is <em>radius</em> and the angle is <em>radians</em>.</p>
<p><code-style></p>
<pre name="code" class="as3">my_mc.x = radius * Math.cos(radians);
my_mc.y = radius * Math.sin(radians);</pre>
<p></code></p>
<p>The second is the formula of transforming coordinates (x, y), which rotates the point around the origin (0, 0) by angle ø.</p>
<p>[2] transform: rotating point (x, y) around the origin (0, 0) by angle ø.</p>
<blockquote><p>x: x cosø &#8211; y sinø<br />
y: x sinø + y cosø</p></blockquote>
<p>The following code rotates a MovieClip instance <em>my_mc</em> around the origin of the parent instance by angle <em>theta</em>.</p>
<p><code-style></p>
<pre name="code" class="as3">var nSin:Number = Math.sin(theta);
var nCos:Number = Math.cos(theta);
var nX:Number = my_mc.x;
var nY:Number = my_mc.y;
my_mc.x = nCos * nX - nSin * nY;
my_mc.y = nSin * nX + nCos * nY;</pre>
<p></code></p>
<p>Formula [2] is superior to [1] to rotate many instances around the origin by the same angle.  The Math.sin() and Math.cos() methods should not be called every time to rotate instances because the angle remains the same.</p>
<p><code-style></p>
<pre name="code" class="as3">var nSin:Number = Math.sin(theta);
var nCos:Number = Math.cos(theta);
//
for (var i:uint = 0; i < count; i++) {
	// get reference of my_mc
	var nX:Number = my_mc.x;
	var nY:Number = my_mc.y;
	my_mc.x = nCos * nX - nSin * nY;
	my_mc.y = nSin * nX + nCos * nY;
}</pre>
<p></code></p>
<p>See the wonderfl test code to compare two ways.</p>
<p><script type="text/javascript" src="http://wonderfl.net/blogparts/nw2f/js"></script>
<p class="ttlBpWonderfl" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://wonderfl.net/c/nw2f" title="Calculating coordinates to rotate">Calculating coordinates to rotate - wonderfl build flash online</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2011/09/22/calculating-coordinates-to-rotate/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Comparing Graphics.drawPath() method with traditional Graphics API</title>
		<link>http://blog.jactionscripters.com/2011/09/13/comparing-graphics-drawpath-method-with-traditional-graphics-api/</link>
		<comments>http://blog.jactionscripters.com/2011/09/13/comparing-graphics-drawpath-method-with-traditional-graphics-api/#comments</comments>
		<pubDate>Mon, 12 Sep 2011 15:37:01 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1453</guid>
		<description><![CDATA[According to the explanation of the [Help] Graphics.drawPath() method is faster than the  traditional Graphics API.
Generally, drawings render faster with drawPath() than with a series of individual lineTo() and curveTo() methods.
However, as long as I tested and compared these methods, any significant differences were not found.
[Drawing API] of the [Help] shows an example code [...]]]></description>
			<content:encoded><![CDATA[<p>According to the explanation of the [Help] <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/Graphics.html#drawPath()" target="_blank">Graphics.drawPath() method</a> is faster than the  traditional Graphics API.</p>
<blockquote><p>Generally, drawings render faster with drawPath() than with a series of individual lineTo() and curveTo() methods.</p></blockquote>
<p>However, as long as I tested and compared these methods, any significant differences were not found.</p>
<p>[<a href="http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c3a0f5f19124318fc87b-7ffe.html">Drawing API</a>] of the [Help] shows an example code using the Graphics.drawPath() method, which runs faster than the Graphics.moveTo() and Graphics.lintTo() methods. But the coordinates to be passed to the methods are stored in a Vector object. The Vector object is directly specified to the Graphics.drawPath() method, while Graphics.moveTo() and Graphics.lintTo() methods have to take numbers out of the Vector object.</p>
<p>The best case to use Graphics.drawPath() method might be to draw the same shape to multiple instances. Once two Vector objects for the methods arguments are created they can be passed to the methods multiple times.  The test code is uploaded to wonderfl.</p>
<p><script type="text/javascript" src="http://wonderfl.net/blogparts/6yyr/js"></script>
<p class="ttlBpWonderfl" style="width: 465px; margin: 0; text-align: right; font-size: 11px;"><a href="http://wonderfl.net/c/6yyr" title="Comparing Graphics.drawPath() method with traditional Graphics API">Comparing Graphics.drawPath() method with traditional Graphics API &#8211; wonderfl build flash online</a></p>
<p>note: &#8220;<a href="http://www.flashandmath.com/howtos/pathalpha/index.html" target="_blank">AS3 graphics.drawPath versus moveTo, lineTo Methods &#8211; Preserving Transparency</a>&#8221; is introduced to the wonderfl post as a comment.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2011/09/13/comparing-graphics-drawpath-method-with-traditional-graphics-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Mysterious class World in Flash CS5</title>
		<link>http://blog.jactionscripters.com/2011/07/30/mysterious-class-world-in-flash-cs5/</link>
		<comments>http://blog.jactionscripters.com/2011/07/30/mysterious-class-world-in-flash-cs5/#comments</comments>
		<pubDate>Sat, 30 Jul 2011 06:51:52 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1430</guid>
		<description><![CDATA[Create a new FLA file in Flash Professional CS5 and write the following frame action:

var test:World = new World();

[Test Movie] generates the compile error #1136:
Incorrect number of arguments. Expected 2.
I have never defined the class World but tried to solve the errors by adding several functions as follows:

var test:World = new World(this, this);
function createWorld() {}
function [...]]]></description>
			<content:encoded><![CDATA[<p>Create a new FLA file in Flash Professional <strong>CS5</strong> and write the following frame action:</p>
<p><code-style></p>
<pre name="code" class="as3">var test:World = new World();</pre>
<p></code></p>
<p>[Test Movie] generates the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/compilerErrors.html#1136" target="_blank">compile error #1136</a>:</p>
<blockquote><p>Incorrect number of arguments. Expected 2.</p></blockquote>
<p>I have never defined the class World but tried to solve the errors by adding several functions as follows:</p>
<p><code-style></p>
<pre name="code" class="as3">var test:World = new World(this, this);
function createWorld() {}
function getStepSize(temp) {}
function setStepSize(temp, temp2) {}
trace(test);  // Output: [object World]</pre>
<p></code></p>
<p>Both Flash CS4 porfessional and Flash Professional CS5.5 don&#8217;t have such class, &#8220;World&#8221;.  I suspect Adobe left the unnecessary class in CS5 by mistake.  You have to be careful if you define the class named &#8220;World&#8221; in CS5.</p>
<p>[postscript: 2011/09/23]<br />
According to the comments below and the blog article &#8220;<a href="http://heftybyte.com/flash/flash-cs5-physics/" target="_blank">Flash CS5 Built-in Physics Discovered</a>&#8220;, the class World is a part of physics engine in the inverse Inverse Kinematics framework.  And once the API was planned to release with the &#8220;Physics&#8221; panel but was abandoned by Adobe.</p>
<p>Based on the blog the following code was written to test the library:</p>
<p><code-style></p>
<pre name="code" class="as3">const COUNT:uint = 50;
var instances:Vector.&lt;Shape&gt; = drawShapes(COUNT);
var physics:PhysicsManager = new PhysicsManager(stage);
var myWorld:World = physics.createWorld();
assignPhysics();
myWorld.enableCollisions(true);
myWorld.setGravity(new Point(0, 200));
stage.addEventListener(MouseEvent.CLICK, startPhysics);
function startPhysics(eventObject:MouseEvent):void {
	addEventListener(Event.ENTER_FRAME, animatePhysics);
}
function assignPhysics():void {
	var myPoint:Point = new Point(1, 1);
	for (var i:uint = 0; i &lt; COUNT; i++) {
		var instance:DisplayObject = instances[i];
		var physicsObject:PhysObj = myWorld.addPhysObj(instance, myPoint, 0, false);
		if (i % 2) {
			physicsObject.setNonMoving(true);
		}
	}
}
function animatePhysics(eventObject:Event):void {
	myWorld.updateAllObjects();
	myWorld.step();
}
function drawShapes(count:uint):Vector.&lt;Shape&gt; {
	var nStageWidth:int = stage.stageWidth;
	var nStageHeight:int = stage.stageHeight;
	var nWidth:Number = 25;
	var nHeight:Number = 5;
	var instances:Vector.&lt;Shape&gt; = new Vector.&lt;Shape&gt;(count);
	for (var i:uint = 0; i &lt; count; i++) {
		var myShape:Shape = new Shape();
		var myGraphics:Graphics = myShape.graphics;
		myGraphics.beginFill(uint(0xFFFFFF * Math.random()));
		myGraphics.drawRect(-nWidth / 2, -nHeight / 2, nWidth, nHeight);
		myGraphics.endFill();
		addChild(myShape);
		instances[i] = myShape;
		myShape.x = nStageWidth * Math.random();
		myShape.y = nStageHeight * Math.random();
		myShape.rotation = 360 * Math.random();
	}
	return instances;
}</pre>
<p></code></p>
<p>Just copy the whole code and paste it into the first frame of  the main timeline in Flash Professional CS5.  Then do [Test Movie] and click on the stage.  A half of instances randomly placed will fall down.</p>
<div id="attachment_1537" class="wp-caption alignnone" style="width: 250px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2011/07/FF1109231_001.gif" alt="Instances are randomly placed on the stage" title="Testing the physics engine" width="240" height="180" class="size-full wp-image-1537" /><p class="wp-caption-text">Instances are randomly placed on the stage</p></div>
<div id="attachment_1537" class="wp-caption alignnone" style="width: 250px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2011/07/FF1109231_003.gif" alt="Click on the stage and a half of Instances fall down" title="Test the physics engine 2" width="240" height="180" class="alignnone size-full wp-image-1538" /><p class="wp-caption-text">Click on the stage and a half of Instances fall down</p></div>
<div id="attachment_1541" class="wp-caption alignnone" style="width: 535px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2011/07/FF1109231_004.gif" alt="Flash Professional CS5 includes the PffLib.swc library file in the application folder" title="PffLib.swc in Flash CS 5" width="525" height="275" class="size-full wp-image-1541" /><p class="wp-caption-text">Flash Professional CS5 includes the PffLib.swc library file in the application holder</p></div>
<p>The API of the physics engine is stored in the application folder of Flash CS5, Adobe Flash CS5/Common/Configuration/ActionScript 3.0/libs.  You may use the file in CS5.5 as well by adding its folder path to the [<a href="http://help.adobe.com/en_US/flash/cs/using/WS3e7c64e37a1d85e1e229110db38dec34-7fa4a.html#WSFE27EB8F-735F-423e-BF7A-56E47357EBD8" target="_blank">Library path</a>] in the [Advanced ActionScript 3.0 Settings].</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2011/07/30/mysterious-class-world-in-flash-cs5/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>When to use the ?: conditional operator</title>
		<link>http://blog.jactionscripters.com/2011/02/09/when-to-use-the-conditional-operator/</link>
		<comments>http://blog.jactionscripters.com/2011/02/09/when-to-use-the-conditional-operator/#comments</comments>
		<pubDate>Tue, 08 Feb 2011 19:13:37 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1396</guid>
		<description><![CDATA[The conditional operator ?: is used to select an alternative value to be assigned.  It is basically faster than the if statement.

myVariable = (condition) ? valueA : valueB;



if (condition) {
	myVariable = valueA;
} else {
	myVariable = valueB;
}

However if the value selected by the conditional operator is to be added with the addition assignment operator +=, [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/operators.html#conditional" target="_blank">conditional operator <em>?:</em></a> is used to select an alternative value to be assigned.  It is <a href="http://wonderfl.net/c/noWZ" target="_blank">basically faster</a> than the <em>if</em> statement.</p>
<p><code-style></p>
<pre name="code" class="as3">myVariable = (condition) ? valueA : valueB;
</pre>
<p></code></p>
<p><code-style></p>
<pre name="code" class="as3">if (condition) {
	myVariable = valueA;
} else {
	myVariable = valueB;
}</pre>
<p></code></p>
<p>However if the value selected by the conditional operator is to be added with the addition assignment operator <em>+=</em>, its operation will come to be slow.</p>
<p><code-style></p>
<pre name="code" class="as3">myVariable += (condition) ? valueA : valueB;</pre>
<p></code></p>
<p>Using the assignment operator <em>=</em> instead makes it a little faster.</p>
<p><code-style></p>
<pre name="code" class="as3">myVariable = (condition) ? myVariable + valueA : myVariable + valueB;</pre>
<p></code></p>
<p>But in this case, the <a href="http://wonderfl.net/c/yXKm" target="_blank"><em>if</em> statement is better</a> to use.</p>
<p><code-style></p>
<pre name="code" class="as3">if (condition) {
	myVariable += valueA;
} else {
	myVariable += valueB;
}</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2011/02/09/when-to-use-the-conditional-operator/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Merging two arrays</title>
		<link>http://blog.jactionscripters.com/2011/01/12/merging-two-arrays/</link>
		<comments>http://blog.jactionscripters.com/2011/01/12/merging-two-arrays/#comments</comments>
		<pubDate>Wed, 12 Jan 2011 13:05:36 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1379</guid>
		<description><![CDATA[Grant Skinner (@gskinner) tweeted a handy trick for merging two arrays in JavaScript.  This can be utilized in ActionScript 3.0 as well.

arr1.push.apply(arr1, arr2);

@gskinner:
Advantage of previous trick vs concat: doesn&#8217;t have the cost of constructing a new array.
I tried to compare speed of this technique with the Array.concat() method&#8217;s.  The results of the first [...]]]></description>
			<content:encoded><![CDATA[<p>Grant Skinner (<a href="http://twitter.com/#!/gskinner" target="_blank">@gskinner</a>) tweeted <a href="http://twitter.com/#!/gskinner/status/24695778207338496" target="_blank">a handy trick</a> for merging two arrays in JavaScript.  This can be utilized in ActionScript 3.0 as well.</p>
<p><code-style></p>
<pre name="code" class="as3">arr1.push.apply(arr1, arr2);</pre>
<p></code></p>
<blockquote><p><a href="http://twitter.com/#!/gskinner/status/24705793982988288" target="_blank">@gskinner</a>:<br />
Advantage of previous trick vs concat: doesn&#8217;t have the cost of constructing a new array.</p></blockquote>
<p>I tried to compare speed of this technique with the <em>Array.concat()</em> method&#8217;s.  The results of <a href="http://wonderfl.net/c/wGXS" target="_blank">the first code</a> posted to wonderfl were varied.  In the code the number of elements in both of source and joined arrays are 300.</p>
<p><a href="http://wonderfl.net/c/sdP4" target="_blank">The second code</a> joins 100 elements arrays to 10000 elements of source.  Then the trick with <em>Function.apply()</em> and <em>Array.push()</em> methods is faster than <em>Array.concat()</em>.  But <a href="http://wonderfl.net/c/12Jz" target="_blank">the third code</a>&#8217;s results are opposite.  It merges additional arrays containing 10000 elements with source arrays containing 100 elements.</p>
<p>From these results referencing an Array instance with <em>Function.apply()</em> method seems to be faster but adding elements with <em>Array.push()</em> method might be slower than <em>Array.concat()</em> method.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2011/01/12/merging-two-arrays/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Correction of a sample code in &#8220;Using the Text Layout Framework&#8221; of the CS5 help</title>
		<link>http://blog.jactionscripters.com/2010/06/02/correction-of-a-sample-code-in-using-the-text-layout-framework-of-the-cs5-help/</link>
		<comments>http://blog.jactionscripters.com/2010/06/02/correction-of-a-sample-code-in-using-the-text-layout-framework-of-the-cs5-help/#comments</comments>
		<pubDate>Wed, 02 Jun 2010 07:18:45 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1325</guid>
		<description><![CDATA[&#8220;Using the Text Layout Framework&#8221; in &#8220;ActionScript 3.0 Developer&#8217;s Guide&#8221; on the Flash CS5 help includes some example codes to show how to use the Text Layout Framework. However, the second example in the section &#8220;The Text Layout Framework View&#8221; yields errors. The following two corrections should be made.
First, insert the xmlns attribute into the [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;<a href="http://help.adobe.com/en_US/as3/dev/WSb2ba3b1aad8a27b0-1b8898a412218ad3df9-8000.html" target="_blank">Using the Text Layout Framework</a>&#8221; in &#8220;ActionScript 3.0 Developer&#8217;s Guide&#8221; on the Flash CS5 help includes some example codes to show how to use the Text Layout Framework. However, <a href="http://help.adobe.com/en_US/as3/dev/WS14c3067b34b57c6d4a97343b122ab36a52f-7ff4.html#WS14c3067b34b57c6d4a97343b122ab36a52f-7ff2" target="_blank">the second example</a> in the section &#8220;<a href="http://help.adobe.com/en_US/as3/dev/WS14c3067b34b57c6d4a97343b122ab36a52f-7ff4.html" target="_blank">The Text Layout Framework View</a>&#8221; yields errors. The following two corrections should be made.</p>
<p>First, insert the xmlns attribute into the Flow element of the XML data (markup).</p>
<blockquote><p><font color="#999999">// var markup:XML = &lt;TextFlow&gt;&lt;p&gt;&lt;span&gt;Hello, World&lt;/span&gt;&lt;/p&gt;&lt;/TextFlow&gt;;</font><br />
var markup:XML = &lt;TextFlow <font color="#0000FF"><strong>xmlns=&#8217;http://ns.adobe.com/textLayout/2008&#8242;</strong></font>&gt;&lt;p&gt;&lt;span&gt;Hello, World&lt;/span&gt;&lt;/p&gt;&lt;/TextFlow&gt;;
</p></blockquote>
<p>Second, the method updateAllContainers() is not implemented in the IFlowComposer interface.  Use the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flashx/textLayout/compose/IFlowComposer.html?filter_flash=cs5&#038;filter_flashplayer=10.1&#038;filter_air=2#updateAllControllers()" target="_blank"><em>updateAllControllers()</em> method</a> instead.</p>
<blockquote><p><font color="#999999">// myFlow.flowComposer.updateAllContainers();</font><br />
myFlow.flowComposer.<strong><font color="#0000FF">updateAllControllers</font></strong>();</p></blockquote>
<p>The corrected frame action below works and shows the text in the top left corner of the stage.</p>
<p><code-style></p>
<pre name="code" class="as3">// import necessary classes
import flashx.textLayout.container.*;
import flashx.textLayout.compose.*;
import flashx.textLayout.elements.TextFlow;
import flashx.textLayout.conversion.TextConverter;

// first, create a TextFlow instance named myFlow
// var markup:XML = &lt;TextFlow&gt;&lt;p&gt;&lt;span&gt;Hello, World&lt;/span&gt;&lt;/p&gt;&lt;/TextFlow&gt;;
var markup:XML = &lt;TextFlow xmlns='http://ns.adobe.com/textLayout/2008'&gt;&lt;p&gt;&lt;span&gt;Hello, World&lt;/span&gt;&lt;/p&gt;&lt;/TextFlow&gt;;
var myFlow:TextFlow = TextConverter.importToFlow(markup, TextConverter.TEXT_LAYOUT_FORMAT);

// second, create a controller
// the first parameter, this, must point to a DisplayObjectContainer
// the last two parameters set the initial size of the container in pixels
var contr:ContainerController = new ContainerController(this, 600, 600);

// third, associate it with the flowComposer property
myFlow.flowComposer.addController(contr);

// fourth, update the display list ;
// myFlow.flowComposer.updateAllContainers();
myFlow.flowComposer.updateAllControllers();</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/06/02/correction-of-a-sample-code-in-using-the-text-layout-framework-of-the-cs5-help/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using a class in flashx.textLayout package prevents the constructor from accessing Stage</title>
		<link>http://blog.jactionscripters.com/2010/05/22/using-a-class-in-flashx-textlayout-package-prevents-the-constructor-from-accessing-stage/</link>
		<comments>http://blog.jactionscripters.com/2010/05/22/using-a-class-in-flashx-textlayout-package-prevents-the-constructor-from-accessing-stage/#comments</comments>
		<pubDate>Sat, 22 May 2010 08:41:33 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1289</guid>
		<description><![CDATA[&#8220;Text Layout Framework example: News layout&#8221; in the [Help] yields the run-time error #1009.  Because using a class in flashx.textLayout package prevents the constructor from accessing the Stage instance.
Note: The code has already been fixed. But it is good to know how to access the Stage object when classes in flashx.textLayout package are used. [...]]]></description>
			<content:encoded><![CDATA[<p>&#8220;<a href="http://help.adobe.com/en_US/as3/dev/WS14c3067b34b57c6d4a97343b122ab36a52f-7fed.html" target="_blank">Text Layout Framework example: News layout</a>&#8221; in the [Help] yields the <a href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/runtimeErrors.html#1009" target="_blank">run-time error #1009</a>.  Because using a class in flashx.textLayout package prevents the constructor from accessing the Stage instance.</p>
<p><strong>Note</strong>: The code has already been fixed. But it is good to know how to access the Stage object when classes in flashx.textLayout package are used. (2010/06/20)</p>
<p>As the test script below shows, the Stage object is available after the <a href="http://help.adobe.com/ja_JP/Flash/CS5/AS3LR/flash/display/DisplayObject.html#event:addedToStage" target="_blank">DisplayObject.addedToStage event</a>, which is dispatched twice.</p>
<p><code-style></p>
<pre name="code" class="as3">package {
	import flash.display.Sprite;
	import flash.events.Event;
	import flashx.textLayout.elements.TextFlow;
	public class TextLayoutFormatTest extends Sprite {
		public function TextLayoutFormatTest() {
			var my_fmt:TextFlow;
			trace("constructor", stage, parent);
			addEventListener(Event.ADDED_TO_STAGE, onAdded);
		}
		private function onAdded(eventObject:Event):void {
			trace(stage, parent);
		}
	}
}</pre>
<p></code></p>
<blockquote><p>// [Output]:<br />
constructor null null<br />
[object Stage] [object Loader]<br />
[object Stage] [object Stage]</p></blockquote>
<p>As for the prior example in the [Help], TLFNewsLayout class, the statements in the constructor should be moved into a listener method of the <em>DisplayObject.addedToStage</em> event as follows:</p>
<p><code-style></p>
<pre name="code" class="as3">package {
	import flash.display.Sprite;
	import flash.display.StageAlign;
	import flash.display.StageScaleMode;
	import flash.events.Event;
	import flash.geom.Rectangle;

	import flashx.textLayout.compose.StandardFlowComposer;
	import flashx.textLayout.container.ContainerController;
	import flashx.textLayout.container.ScrollPolicy;
	import flashx.textLayout.conversion.TextConverter;
	import flashx.textLayout.elements.TextFlow;
	import flashx.textLayout.formats.TextLayoutFormat;

	public class TLFNewsLayout extends Sprite {
		private var hTextFlow:TextFlow;
		private var headContainer:Sprite;
		private var headlineController:ContainerController;
		private var hContainerFormat:TextLayoutFormat;

		private var bTextFlow:TextFlow;
		private var bodyTextContainer:Sprite;
		private var bodyController:ContainerController;
		private var bodyTextContainerFormat:TextLayoutFormat;

		private const headlineMarkup:String = "<flow:TextFlow xmlns:flow='http://ns.adobe.com/textLayout/2008'><flow:p textAlign='center'><flow:span fontFamily='Helvetica' fontSize='18'>TLF News Layout Example</flow:span><flow:br/><flow:span fontFamily='Helvetica' fontSize='14'>This example formats text like a newspaper page with a headline, a subtitle, and multiple columns</flow:span></flow:p></flow:TextFlow>";

		private const bodyMarkup:String = "<flow:TextFlow xmlns:flow='http://ns.adobe.com/textLayout/2008' fontSize='12' textIndent='10' marginBottom='15' paddingTop='4' paddingLeft='4'><flow:p marginBottom='inherit'><flow:span>There are many </flow:span><flow:span fontStyle='italic'>such</flow:span><flow:span> lime-kilns in that tract of country, for the purpose of burning the white marble which composes a large part of the substance of the hills. Some of them, built years ago, and long deserted, with weeds growing in the vacant round of the interior, which is open to the sky, and grass and wild-flowers rooting themselves into the chinks of the stones, look already like relics of antiquity, and may yet be overspread with the lichens of centuries to come. Others, where the lime-burner still feeds his daily and nightlong fire, afford points of interest to the wanderer among the hills, who seats himself on a log of wood or a fragment of marble, to hold a chat with the solitary man. It is a lonesome, and, when the character is inclined to thought, may be an intensely thoughtful occupation; as it proved in the case of Ethan Brand, who had mused to such strange purpose, in days gone by, while the fire in this very kiln was burning.</flow:span></flow:p><flow:p marginBottom='inherit'><flow:span>The man who now watched the fire was of a different order, and troubled himself with no thoughts save the very few that were requisite to his business. At frequent intervals, he flung back the clashing weight of the iron door, and, turning his face from the insufferable glare, thrust in huge logs of oak, or stirred the immense brands with a long pole. Within the furnace were seen the curling and riotous flames, and the burning marble, almost molten with the intensity of heat; while without, the reflection of the fire quivered on the dark intricacy of the surrounding forest, and showed in the foreground a bright and ruddy little picture of the hut, the spring beside its door, the athletic and coal-begrimed figure of the lime-burner, and the half-frightened child, shrinking into the protection of his father's shadow. And when again the iron door was closed, then reappeared the tender light of the half-full moon, which vainly strove to trace out the indistinct shapes of the neighboring mountains; and, in the upper sky, there was a flitting congregation of clouds, still faintly tinged with the rosy sunset, though thus far down into the valley the sunshine had vanished long and long ago.</flow:span></flow:p></flow:TextFlow>";

		public function TLFNewsLayout() {
			addEventListener(Event.ADDED_TO_STAGE, initialize);
		}
		function initialize(eventObject:Event):void {
			removeEventListener(Event.ADDED_TO_STAGE, initialize);
			stage.scaleMode = StageScaleMode.NO_SCALE;
			stage.align = StageAlign.TOP_LEFT;

			// Headline text flow and flow composer
			hTextFlow = TextConverter.importToFlow(headlineMarkup,TextConverter.TEXT_LAYOUT_FORMAT);
			hTextFlow.flowComposer = new StandardFlowComposer();

			// initialize the headline container and controller objects
			headContainer = new Sprite();
			headlineController = new ContainerController(headContainer);
			headlineController.verticalScrollPolicy = ScrollPolicy.OFF;
			hContainerFormat = new TextLayoutFormat();
			hContainerFormat.paddingTop = 4;
			hContainerFormat.paddingRight = 4;
			hContainerFormat.paddingBottom = 4;
			hContainerFormat.paddingLeft = 4;

			headlineController.format = hContainerFormat;
			hTextFlow.flowComposer.addController(headlineController);
			addChild(headContainer);
			stage.addEventListener(flash.events.Event.RESIZE, resizeHandler);

			// Body text TextFlow and flow composer
			bTextFlow = TextConverter.importToFlow(bodyMarkup,TextConverter.TEXT_LAYOUT_FORMAT);
			bTextFlow.flowComposer = new StandardFlowComposer();

			// The body text container is below, and has three columns
			bodyTextContainer = new Sprite();
			bodyController = new ContainerController(bodyTextContainer);
			bodyTextContainerFormat = new TextLayoutFormat();
			bodyTextContainerFormat.columnCount = 3;
			bodyTextContainerFormat.columnGap = 30;

			bodyController.format = bodyTextContainerFormat;
			bTextFlow.flowComposer.addController(bodyController);
			addChild(bodyTextContainer);
			resizeHandler(null);
		}

		private function resizeHandler(event:Event):void {
			const verticalGap:Number = 25;
			const stagePadding:Number = 16;
			var stageWidth:Number = stage.stageWidth - stagePadding;
			var stageHeight:Number = stage.stageHeight - stagePadding;
			var headlineWidth:Number = stageWidth;
			var headlineContainerHeight:Number = stageHeight;

			// Initial compose to get height of headline after resize
			headlineController.setCompositionSize(headlineWidth, headlineContainerHeight);
			hTextFlow.flowComposer.compose();
			var rect:Rectangle = headlineController.getContentBounds();
			headlineContainerHeight = rect.height;

			// Resize and place headline text container
			// Call setCompositionSize() again with updated headline height
			headlineController.setCompositionSize(headlineWidth, headlineContainerHeight );
			headlineController.container.x = stagePadding / 2;
			headlineController.container.y = stagePadding / 2;
			hTextFlow.flowComposer.updateAllControllers();

			// Resize and place body text container ;
			var bodyContainerHeight:Number = (stageHeight - verticalGap - headlineContainerHeight);
			bodyController.format = bodyTextContainerFormat;
			bodyController.setCompositionSize(stageWidth, bodyContainerHeight );
			bodyController.container.x = (stagePadding/2);
			bodyController.container.y = (stagePadding/2) + headlineContainerHeight + verticalGap;
			bTextFlow.flowComposer.updateAllControllers();
		}
	}
}</pre>
<p></code></p>
<div id="attachment_1319" class="wp-caption alignnone" style="width: 562px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2010/05/TLFNewsLayout.gif" alt="The result of the TLFNewsLayout class" title="TLFNewsLayout" width="552" height="402" class="size-full wp-image-1319" /><p class="wp-caption-text">The result of the TLFNewsLayout class</p></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/05/22/using-a-class-in-flashx-textlayout-package-prevents-the-constructor-from-accessing-stage/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>NTT DoCoMo SH-07B Standby Widgets</title>
		<link>http://blog.jactionscripters.com/2010/05/18/ntt-docomo-sh-07b-standby-widgets/</link>
		<comments>http://blog.jactionscripters.com/2010/05/18/ntt-docomo-sh-07b-standby-widgets/#comments</comments>
		<pubDate>Tue, 18 May 2010 08:21:05 +0000</pubDate>
		<dc:creator>Yoshihiro Shindo</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Showcase]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1284</guid>
		<description><![CDATA[Today, the NTT DoCoMo has released some new products and services for this summer. One of them, &#8220;SH-07B&#8221; which is released from SHARP Corporation, has new function called &#8220;Standby Widgets&#8221; that was implemented by Yoshihiro Shindo (BeInteractive!, it&#8217;s me) and Yusuke Nakahara who belongs to the CD-IM. It was directed by Naoki Mima who belongs [...]]]></description>
			<content:encoded><![CDATA[<p>Today, the NTT DoCoMo has released some new products and services for this summer. One of them, &#8220;<a href="http://www.sharp.co.jp/products/sh07b/">SH-07B</a>&#8221; which is released from SHARP Corporation, has new function called &#8220;Standby Widgets&#8221; that was implemented by Yoshihiro Shindo (<a href="http://www.be-interactive.org/">BeInteractive!</a>, it&#8217;s me) and Yusuke Nakahara who belongs to the <a href="http://www.cd-im.jp/">CD-IM</a>. It was directed by Naoki Mima who belongs to the <a href="http://www.rightning.com/">Rightninc, Inc</a>. What I mentioned in my presentation at the FITC Toronto 2010 is about this.</p>
<p>&#8220;Standby Widgets&#8221; is a function that enables you to customize your standby screen. You can add, remove, or lay out built-in widgets as you like. There are some built-in widgets like bookmarks, calendar, and manner mode switch. Also you can change widget&#8217;s color to your favorite color. For phone and mail, it has a list that you can access recent calls or mails easily.</p>
<p><p>In all honesty, it&#8217;s not an amazing new function. However, a point is why the team has invited me. Can you make sense? Yes, it&#8217;s written by Flash (FlashLite). A special customized FlashLite engine has been provided by the device team, and all of &#8220;Standby Widgets&#8221; is running on it. This is our first answer of a question &#8220;Can we make better UI if we could use Flash?&#8221;.</p>
<p>Many Japanese mobile phone is high-spec actually, but its UI ruins the value of it, I think. In my view, this project is to improve it. Also I feel this project provides fun future to not only users of device but also Flash developers in the world.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/05/18/ntt-docomo-sh-07b-standby-widgets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>TETRIS on the beat !</title>
		<link>http://blog.jactionscripters.com/2010/05/15/tetris-on-the-beat/</link>
		<comments>http://blog.jactionscripters.com/2010/05/15/tetris-on-the-beat/#comments</comments>
		<pubDate>Fri, 14 May 2010 20:16:12 +0000</pubDate>
		<dc:creator>keim</dc:creator>
				<category><![CDATA[Library]]></category>
		<category><![CDATA[Showcase]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1270</guid>
		<description><![CDATA[
SiON TETRISizer &#8211; wonderfl build flash online
This is new demonstration of my AS3 software synthesize &#8216;SiON&#8217;. This work may remind someone of &#8216;LUMINES&#8217; (of cause this is one of my favorite games). The SiON can bring its feeling to your flash.
In this flash, I also use various libraries, betweenas3, froce55ing, minimalcomps and papervision3d.
I would like [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-1271" href="http://blog.jactionscripters.com/2010/05/15/tetris-on-the-beat/tetrision/"><img class="alignnone size-full wp-image-1271" title="Tetrision" src="http://blog.jactionscripters.com/wp-content/uploads/2010/05/Tetrision.png" alt="Tetrision" width="640" height="320" /></a></p>
<p><a title="SiON TETRISizer - wonderfl build flash online" href="http://wonderfl.net/c/f5eX">SiON TETRISizer &#8211; wonderfl build flash online</a></p>
<p>This is new demonstration of my AS3 software synthesize <a href="http://www.libspark.org/wiki/keim/SiON_e" target="_blank">&#8216;SiON&#8217;</a>. This work may remind someone of <a href="http://en.wikipedia.org/wiki/Lumines">&#8216;LUMINES&#8217;</a> (of cause this is one of my favorite games). The SiON can bring its feeling to your flash.<br />
In this flash, I also use various libraries, <a href="http://www.libspark.org/wiki/BetweenAS3/en">betweenas3</a>, <a href="http://www.libspark.org/wiki/nutsu/Frocessing/en">froce55ing</a>, <a href="http://www.minimalcomps.com/">minimalcomps</a> and <a href="http://blog.papervision3d.org/">papervision3d</a>.<br />
I would like to say thank you for all authors of these useful libraries.</p>
<p>Enjoy !</p>
<p><a href="http://www.libspark.org/wiki/keim/SiON_e" target="_blank">AS3 software synthesizer SiON Development Center</a> in <a href="http://www.libspark.org/wiki/WikiStart/en" target="_blank">spark project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/05/15/tetris-on-the-beat/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Decrement versus Increment in Loop 2</title>
		<link>http://blog.jactionscripters.com/2010/05/01/decrement-versus-increment-in-loop-2/</link>
		<comments>http://blog.jactionscripters.com/2010/05/01/decrement-versus-increment-in-loop-2/#comments</comments>
		<pubDate>Sat, 01 May 2010 06:05:18 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1233</guid>
		<description><![CDATA[Adobe&#8217;s &#8220;Optimizing Performance for the Flash Platform&#8221; recommends that &#8220;Use reverse order for while loops&#8221; in its &#8220;Miscellaneous optimizations&#8221; section.  And in my last post, decrement was not explicitly faster than increment with the following code to compare them:


while (--i > -1)




while (++i < MAX_NUMBER)  // MAX_NUMBER is a constant


Difference was very little [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe&#8217;s &#8220;Optimizing Performance for the Flash Platform&#8221; recommends that &#8220;Use reverse order for while loops&#8221; in its &#8220;<a href="http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c3a0f5f19124318fc87b-7ffc.html" target="_blank">Miscellaneous optimizations</a>&#8221; section.  And in <a href="http://blog.jactionscripters.com/2010/04/12/decrement-versus-increment-in-loop/" target="_blank">my last post</a>, decrement was not explicitly faster than increment with <a href="http://wonderfl.net/c/pB5I" target="_blank">the following code</a> to compare them:</p>
<p><code-style></p>
<pre name="code" class="as3">
while (--i > -1)
</pre>
<p></code></p>
<p><code-style></p>
<pre name="code" class="as3">
while (++i < MAX_NUMBER)  // MAX_NUMBER is a constant
</pre>
<p></code></p>
<p>Difference was very little in my Mac OS environment. But in Internet Explorer 7 and Firefox 3/Flash Player 10/Windows Vista, decrement was faster up to twenty percent than increment.  After several trials, speed of operation between decrement and increment seems to be almost the same.  The condition of loop does not care if expression is decrement or increment.</p>
<p>The difference came from value to be compared with a counter variable. <a href="http://wonderfl.net/c/li9w" target="_blank">The new sample script</a> for increment below does not use a constant in the condition. Then its speed seems to be almost identical to the decrement's.</p>
<p><code-style></p>
<pre name="code" class="as3">
while (++i < &lt;the literal number&gt;)
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/05/01/decrement-versus-increment-in-loop-2/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>AS3/Flash10 software synthesizer SiON goes to version 0.6</title>
		<link>http://blog.jactionscripters.com/2010/04/26/as3flash10-software-synthesizer-sion-goes-to-version-0-6/</link>
		<comments>http://blog.jactionscripters.com/2010/04/26/as3flash10-software-synthesizer-sion-goes-to-version-0-6/#comments</comments>
		<pubDate>Mon, 26 Apr 2010 14:49:09 +0000</pubDate>
		<dc:creator>keim</dc:creator>
				<category><![CDATA[Library]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1216</guid>
		<description><![CDATA[
Now, the ActionScript software synthesizer &#8220;SiON&#8221; is updated to version 0.6. You can get the newest version from following link.
SiON Development Center in spark project
SiON version 0.60 ASDoc
In the SiON version 0.6, the interfaces are basically same as previous, but it suggests one new feature &#8220;SoundObject&#8221;. Here&#8217;s the example on wonderfl.
SiON SoundObject Quartet
The Arpeggiator, BassSequencer, [...]]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-1215" href="http://blog.jactionscripters.com/2010/04/26/as3flash10-software-synthesizer-sion-goes-to-version-0-6/abcd/"><img class="size-full wp-image-1215" title="ABCD" src="http://blog.jactionscripters.com/wp-content/uploads/2010/04/ABCD.png" alt="SiON goes to version 0.60" width="640" height="240" /></a></p>
<p>Now, the ActionScript software synthesizer &#8220;SiON&#8221; is updated to version 0.6. You can get the newest version from following link.</p>
<p><a href="http://www.libspark.org/wiki/keim/SiON_e" target="_blank">SiON Development Center</a> in <a href="http://www.libspark.org/wiki/WikiStart/en" target="_blank">spark project</a><br />
<a href="http://www.libspark.org/htdocs/as3/sion/index.html" target="_blank">SiON version 0.60 ASDoc</a></p>
<p>In the SiON version 0.6, the interfaces are basically same as previous, but it suggests one new feature &#8220;SoundObject&#8221;. Here&#8217;s the example on wonderfl.</p>
<p><a href="http://wonderfl.net/c/9Xx7">SiON SoundObject Quartet</a></p>
<p>The Arpeggiator, BassSequencer, ChordPad and DrumMachine are the inheritances of SiON SoundObject. The SoundObject brings an feeling of &#8216;DisplayObject&#8217; to the operations of SiON&#8217;s synthesizer.</p>
<p>Let us explore a tidbit of sample&#8217;s source code. The concept of SiON SoundObject consists of 4 modules, the SiONDriver, SoundObjects, Synthesizers and Effectors (shown in line 16~54).</p>
<p>The SiONDriver is the centeral processing unit of all SiON&#8217;s sound, you have to create one new SiONDriver and call play() method. And you might access some SiONDriver&#8217;s properties and methods to set up general settings (BPM, effector and so on) (shown in line 76~83).<br />
<code>driver = new SiONDriver(); (line 65)<br />
...<br />
driver.autoStop = true;              // set auto stop after fade out<br />
driver.bpm = 132;                    // BPM = 132<br />
driver.effector.slot0 = [equaliser]; // The equaliser is applied to slot0 (master effector)<br />
driver.effector.slot1 = [delay];     // The delay effector is applied to slot1 (global effector)<br />
driver.effector.slot2 = [chorus];    // The chorus effector is applied to slot2 (global effector)<br />
driver.addEventListener(SiONTrackEvent.BEAT, _onBeat);           // handler for each beat<br />
driver.addEventListener(SiONEvent.STREAM_START, _onStartStream); // handler when streaming starts<br />
driver.addEventListener(SiONEvent.STREAM_STOP,  _onStopStream);  // handler when streaming stopped<br />
...<br />
driver.play(null, false); (line 193)<br />
</code><br />
The SoundObjects provides a sequence controler. You can control the sounding patterns in real time by properties (following code is from Arpeggiator&#8217;s setting line 91~101). In this exapmle, you can feel the SoundObject&#8217;s sound controling especially in the Arpeggiator&#8217;s large square pad. All SoundObject classes belong to <a href="http://www.libspark.org/htdocs/as3/sion/index.html?org/si/sound/package-detail.html&amp;org/si/sound/class-list.html">org.si.sound package</a>.<br />
<code>Ar = new Arpeggiator();<br />
Ar.scaleName = "o6Emp";             // scaled in E minor pentatonic on octave 6<br />
Ar.pattern = [0,1,2,3,4,2,3,1];     // basic pattern is "egababg" in MML<br />
Ar.noteLength = 1;                  // note langth = 16th<br />
Ar.gateTime = 0.2;                  // gate time = 0.2<br />
Ar.effectors = [autopan];           // apply auto-panning effector to Arpeggiator (local effector)<br />
Ar.volume = 0.3;                    // dry volume = 0.3<br />
Ar.effectSend1 = Ar.volume * 0.4;   // effect send for slot1 = 0.3 * 0.4 = 0.12<br />
Ar.effectSend2 = Ar.volume * 0.5;   // effect send for slot2 = 0.3 * 0.4 = 0.15<br />
...<br />
Ar.play(); (line 198)<br />
</code></p>
<p>The Synthesizers provides a voice controler. This class simplifys the SiONVoice&#8217;s settings, and supports a real-time voice charactor chagings on a SoundObject. In this example, some components are connected to the synthesizer&#8217;s properties (especially in BassSequencer&#8217;s envelop controls) and you may feel the voice character changing on it. (following code is from Arpeggiator&#8217;s WaveTableSynth line 106~109). All synthesizer classes belong to <a href="http://www.libspark.org/htdocs/as3/sion/index.html?org/si/sound/synthesizers/package-detail.html&amp;org/si/sound/synthesizers/class-list.html">org.si.sound.synthesizers package</a>.<br />
<code>waveTableSynth = new WaveTableSynth();<br />
waveTableSynth.color = 0x1203acff;  // wavecolor value<br />
waveTableSynth.releaseTime = 0.2;   // release time<br />
Ar.synthesizer = waveTableSynth;    // apply synthesizer<br />
</code></p>
<p>The Effectors represents the sound effector units. You can apply effectors to the SoundObject like filters to the DisplayObject (please refer above code).<br />
One remarkable point on effectors is that there are 3 types of connections, master, global and local effector. The master effector preocesses the final output of all SiON&#8217;s sound, the global effector preocesses the effect send pipe and the local effector processes only one SoundObject&#8217;s output. The arrow diagram of effector connection is as shown in below figure. All effector classes belong to <a href="http://www.libspark.org/htdocs/as3/sion/index.html?org/si/sion/effector/package-detail.html&amp;org/si/sion/effector/class-list.html">org.si.sion.effector package</a>.</p>
<div id="attachment_1217" class="wp-caption alignnone" style="width: 490px"><a rel="attachment wp-att-1217" href="http://blog.jactionscripters.com/2010/04/26/as3flash10-software-synthesizer-sion-goes-to-version-0-6/sioneffectconnection/"><img class="size-full wp-image-1217" title="SiONEffectConnection" src="http://blog.jactionscripters.com/wp-content/uploads/2010/04/SiONEffectConnection.png" alt="SiON SoundObject's Effector connection arrow diagram" width="480" height="180" /></a><p class="wp-caption-text">SiON SoundObject&#39;s Effector connection arrow diagram</p></div>
<p>The SiON&#8217;s SoundObject brings the simple interactive synthesizers to your flash contents. Enjoy it !</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/04/26/as3flash10-software-synthesizer-sion-goes-to-version-0-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Decrement versus Increment in Loop</title>
		<link>http://blog.jactionscripters.com/2010/04/12/decrement-versus-increment-in-loop/</link>
		<comments>http://blog.jactionscripters.com/2010/04/12/decrement-versus-increment-in-loop/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 02:28:21 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1198</guid>
		<description><![CDATA[Adobe&#8217;s &#8220;Optimizing Performance for the Flash Platform&#8221; recommends that &#8220;Use reverse order for while loops&#8221; in its &#8220;Miscellaneous optimizations&#8221; section.


while (--i > -1)


But according to my test significant difference could not be found between  decrement and increment.  In other language they said that decrement and increment are identical.
The pre-increment/decrement is a little faster [...]]]></description>
			<content:encoded><![CDATA[<p>Adobe&#8217;s &#8220;Optimizing Performance for the Flash Platform&#8221; recommends that &#8220;Use reverse order for while loops&#8221; in its &#8220;<a href="http://help.adobe.com/en_US/as3/mobile/WS4bebcd66a74275c3a0f5f19124318fc87b-7ffc.html" target="_blank">Miscellaneous optimizations</a>&#8221; section.</p>
<p><code-style></p>
<pre name="code" class="as3">
while (--i > -1)
</pre>
<p></code></p>
<p>But according to <a href="http://wonderfl.net/code/b367bc355256e499f86580359b5120053aa13c49" target="_blank">my test</a> significant difference could not be found between  decrement and increment.  In other language they said that <a href="http://social.msdn.microsoft.com/Forums/en-US/wptk_v4/thread/2e73042e-3ed4-4b16-a8e6-c3d5c350ff89" target="_blank">decrement and increment are identical</a>.</p>
<p>The pre-increment/decrement is a little faster than post, which is included in my test, though.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/04/12/decrement-versus-increment-in-loop/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Quaternion notation of Vector3D</title>
		<link>http://blog.jactionscripters.com/2010/04/02/quaternion-notation-of-vector3d/</link>
		<comments>http://blog.jactionscripters.com/2010/04/02/quaternion-notation-of-vector3d/#comments</comments>
		<pubDate>Fri, 02 Apr 2010 09:30:52 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1135</guid>
		<description><![CDATA[The [Help] of the Vecror3D.w property mentions about the quaternion notation as follows:
Quaternion notation employs an angle as the fourth element in its calculation of three-dimensional rotation. The w property can be used to define the angle of rotation about the Vector3D object.
But this sounds like explanation of the axis angle (see Orientation3D .AXIS_ANGLE Constant). [...]]]></description>
			<content:encoded><![CDATA[<p>The [Help] of the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Vector3D.html#w" target="_blank">Vecror3D.w property</a> mentions about the quaternion notation as follows:</p>
<blockquote><p>Quaternion notation employs an angle as the fourth element in its calculation of three-dimensional rotation. The w property can be used to define the angle of rotation about the Vector3D object.</p></blockquote>
<p>But this sounds like explanation of the axis angle (see <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Orientation3D.html#AXIS_ANGLE" target="_blank">Orientation3D .AXIS_ANGLE Constant</a>).  The axis angle uses a combination of an axis and an angle to determine the rotation.  For an argument of the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Matrix3D.html#decompose()" target="_blank">Matrix3D.decompose()</a> or <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Matrix3D.html#recompose()" target="_blank">Matrix3D.recompose()</a> method Orientation3D.AXIS_ANGLE can be specified as the orientation style used for the matrix transformation.</p>
<p>Try to rotate a Matrix3D object 180 degrees (&pi;) around the axis (1/&radic;2, 1/&radic;2, 0).</p>
<p><img src="http://blog.jactionscripters.com/wp-content/uploads/2010/04/ActionScript30for3D_04_054.gif" alt="The axis of rotation" title="The axis of rotation" width="362" height="362" class="alignnone size-full wp-image-1145" /></p>
<p><code-style></p>
<pre name="code" class="as3">
var myMatrix3D:Matrix3D = new Matrix3D();
var axis:Vector3D = new Vector3D(Math.SQRT1_2, Math.SQRT1_2,0);
myMatrix3D.prependRotation(180, axis);
var axisAngle:Vector3D = myMatrix3D.decompose(Orientation3D.AXIS_ANGLE)[1];
trace(axisAngle, axisAngle.w);
</pre>
<p></code></p>
<p>The frame action above outputs as follows:</p>
<blockquote><p>Vector3D(0.7071067094802856, 0.7071068286895752, -2.339619844353034e-24) 3.1415927410125732
</p></blockquote>
<p>[Note]: 0.707&#8230; = 1/&radic;2 and 3.14&#8230; = &pi; radians = 180 degrees.</p>
<p>The (x, y, z) coordinates represents the axis and Vector3D.w property is an angle of the rotation.  This result seems to fit the explanation of the [Help] quoted above.</p>
<p>But the quaternion notation determine the rotation by the four value.  The following expression of the quaternion Q represents the rotation of &theta; around the vector U.</p>
<blockquote><p>U = (x, y, z) and |U| = 1<br />
Q = (cos(&theta;/2); sin(&theta;/2)U)
</p></blockquote>
<p>Then try to rotate a Matrix3D object 60 degrees around the y axis (0, 1, 0).</p>
<p><code-style></p>
<pre name="code" class="as3">
var myMatrix3D:Matrix3D = new Matrix3D();
myMatrix3D.prependRotation(60, Vector3D.Y_AXIS);
var quaternion:Vector3D = myMatrix3D.decompose(Orientation3D.QUATERNION)[1];
trace(quaternion.w, quaternion);
</pre>
<p></code></p>
<p> The frame action above outputs as follows:</p>
<blockquote><p>0.8660253882408142 Vector3D(0, 0.4999999701976776, 0)</p></blockquote>
<p>These numbers represent the quaternion of 60 degrees&#8217; rotation.</p>
<blockquote><p>0.866&#8230; = cos(60/2) = cos(30)<br />
(0, 0.5, 0) = sin(60/2) (0, 1, 0)</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/04/02/quaternion-notation-of-vector3d/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Return value of Matrix3D.recompose() method</title>
		<link>http://blog.jactionscripters.com/2010/03/05/return-value-of-matrix3d-recompose-method/</link>
		<comments>http://blog.jactionscripters.com/2010/03/05/return-value-of-matrix3d-recompose-method/#comments</comments>
		<pubDate>Thu, 04 Mar 2010 16:38:34 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1108</guid>
		<description><![CDATA[The [Help] of the Matrix3D.recompose() method tells about its return value as follows:
Returns false if any of the scale elements are zero.
But this is not true.  Try the code below, in the 7th statement of which the third element, the z coordinate, of the scale Vector3D instance is set to zero.


var myMatrix3D:Matrix3D = new [...]]]></description>
			<content:encoded><![CDATA[<p>The [Help] of the <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Matrix3D.html#recompose()"><em>Matrix3D.recompose()</em> method</a> tells about its return value as follows:</p>
<blockquote><p>Returns false if any of the scale elements are zero.</p></blockquote>
<p>But this is not true.  Try the code below, in the 7th statement of which the third element, the z coordinate, of the scale Vector3D instance is set to zero.</p>
<p><code-style></p>
<pre name="code" class="as3">
var myMatrix3D:Matrix3D = new Matrix3D();
trace(myMatrix3D.decompose());
// Output: Vector3D(0, 0, 0),Vector3D(0, 0, 0),Vector3D(1, 1, 1)
var myVector:Vector.&lt;Vector3D&gt; = new Vector.&lt;Vector3D&gt;();
myVector.push(new Vector3D());  // translation
myVector.push(new Vector3D());  // rotation
myVector.push(new Vector3D(1, 1, 0));  // scale
trace(myMatrix3D.recompose(myVector));
// Output: true
trace(myMatrix3D.decompose());
// Output: Vector3D(0, -1.9986319541931152, 0),Vector3D(-1.5707963705062866, NaN, 0),Vector3D(7.667765755019554e-19, -1.998608112335205, 1.9719639421382673e-19)
</pre>
<p></code></p>
<p>The method returns <em>true</em> as long as the argument of Vector instance has three Vector3D elements.  Therefore, the explanation in the [Help] should be rewritten as follows:</p>
<blockquote><p>Returns false if any of the Vector3D elements of the Vector instance as the argument don&#8217;t exist or are null.</p></blockquote>
<p><strong>Note</strong>: The coordinates of Vector3D elements come to be invalid values if any of the scale elements are zero.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/03/05/return-value-of-matrix3d-recompose-method/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

