<?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 &#187; Coding</title>
	<atom:link href="http://blog.jactionscripters.com/category/coding/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>Sun, 20 Jun 2010 10:03:26 +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>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>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>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>3</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>
		<item>
		<title>Calculation in the Utils3D.projectVectors() method</title>
		<link>http://blog.jactionscripters.com/2010/02/01/calculation-in-the-utils3d-projectvectors-method/</link>
		<comments>http://blog.jactionscripters.com/2010/02/01/calculation-in-the-utils3d-projectvectors-method/#comments</comments>
		<pubDate>Sun, 31 Jan 2010 23:11:06 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1073</guid>
		<description><![CDATA[The Utils3D.projectVectors() method projects a Vector of three-dimensional space coordinates to a Vector of two-dimensional space coordinates.  And the method also sets the t value of the uvt data.
The Utils3D.projectVectors() method calculates t value of the uvt data by the following formula:
t value = 1 / (Distance to the origin + z coordinate value)
Also, [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/Utils3D.html#projectVectors()" target="_blank"><em>Utils3D.projectVectors()</em> method</a> projects a Vector of three-dimensional space coordinates to a Vector of two-dimensional space coordinates.  And the method also sets the t value of the uvt data.</p>
<div id="attachment_1078" class="wp-caption alignnone" style="width: 325px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2010/02/Utils3D_projectVectors1.gif" alt="Calculation in the Utils3D.projectVectors() method" title="Utils3D.projectVectors() method" width="315" height="180" class="size-full wp-image-1078" /><p class="wp-caption-text">Values for the calculation in the Utils3D.projectVectors() method</p></div>
<p>The <em>Utils3D.projectVectors() </em>method calculates t value of the uvt data by the following formula:</p>
<blockquote><p>t value = 1 / (Distance to the origin + z coordinate value)</p></blockquote>
<p>Also, the method calculates projected x and y values by the following formula:</p>
<blockquote><p>Projected x or y value = Three-dimensional space x or y coordinate * Focal length * t value</p></blockquote>
<p>The frame action below compares the results of calculation by the formulas above with the methods&#8217;.  And [Output] is as follows:</p>
<blockquote><p>0,0,0.0004  // uvt data<br />
0.0004  // Calculated t value<br />
20,20  // Projected x and y coordinates<br />
20  // Calculated two-dimensional space x or y coordinate  </p></blockquote>
<p><code-style></p>
<pre name="code" class="as3">
var myPerspective:PerspectiveProjection = new PerspectiveProjection();
var myMatrix3D:Matrix3D = new Matrix3D();
var nDistance:Number = 1000;  // Distance to the origin
var nX:Number = 100;  // Three-dimensional space x or y coordinate
var nZ:Number = 1500;  // Three-dimensional z coordinate
var vertices3D:Vector.&lt;Number&gt; = Vector.&lt;Number&gt;([nX, nX, nZ]);
var vertices2D:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;();
var uvtData:Vector.&lt;Number&gt; = Vector.&lt;Number&gt;([0, 0, 0]);
var nT:Number = 1/(nDistance + nZ);  // t value
myPerspective.focalLength = 500;  // Focal length 
myMatrix3D.appendTranslation(0, 0, nDistance);
myMatrix3D.append(myPerspective.toMatrix3D());
Utils3D.projectVectors(myMatrix3D, vertices3D, vertices2D, uvtData);
trace(uvtData);  // uvt data
trace(nT);  // Calculated t value
trace(vertices2D);  // Projected x and y coordinates
trace(nX * myPerspective.focalLength * nT);  // Calculated two-dimensional space x or y coordinate
</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2010/02/01/calculation-in-the-utils3d-projectvectors-method/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Rotating an instance with the y axis</title>
		<link>http://blog.jactionscripters.com/2009/12/05/rotating-an-instance-with-the-y-axis/</link>
		<comments>http://blog.jactionscripters.com/2009/12/05/rotating-an-instance-with-the-y-axis/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 13:33:10 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=1017</guid>
		<description><![CDATA[Try to rotate a MovieClip instance named my_mc 80 degrees with the y axis.  The trace() function in the code below displays information in the [Output] panel as follows: 
80.00003182368921 1.3962639570236206


var nRotationY:Number = 80;
my_mc.rotationY = 0;
var myMatrix3D:Matrix3D = my_mc.transform.matrix3D;
myMatrix3D.prependRotation(nRotationY, Vector3D.Y_AXIS);
trace(my_mc.rotationY, myMatrix3D.decompose()[1].y);



Then change the number of degrees in the variable, nRotationY, to 100. The code [...]]]></description>
			<content:encoded><![CDATA[<p>Try to rotate a MovieClip instance named my_mc 80 degrees with the y axis.  The trace() function in the code below displays information in the [Output] panel as follows: </p>
<blockquote><p>80.00003182368921 1.3962639570236206</p></blockquote>
<p><code-style></p>
<pre name="code" class="as3">
var nRotationY:Number = 80;
my_mc.rotationY = 0;
var myMatrix3D:Matrix3D = my_mc.transform.matrix3D;
myMatrix3D.prependRotation(nRotationY, Vector3D.Y_AXIS);
trace(my_mc.rotationY, myMatrix3D.decompose()[1].y);
</pre>
<p></code></p>
<p><img src="http://blog.jactionscripters.com/wp-content/uploads/2009/12/rotationTest_80.gif" alt="Rotating an instance 80 degrees" title="Rotating an instance 80 degrees" width="270" height="235" class="alignnone size-full wp-image-1023" /></p>
<p>Then change the number of degrees in the variable, nRotationY, to 100. The code seems to rotate an instance 100 degrees. However, the number of degrees shown in the [Output] panel is still 80.</p>
<blockquote><p>80.00003182368921 1.3962639570236206</p></blockquote>
<p><code-style></p>
<pre name="code" class="as3">
var nRotationY:Number = 100;  // 80;
my_mc.rotationY = 0;
var myMatrix3D:Matrix3D = my_mc.transform.matrix3D;
myMatrix3D.prependRotation(nRotationY, Vector3D.Y_AXIS);
trace(my_mc.rotationY, myMatrix3D.decompose()[1].y);
</pre>
<p></code></p>
<p><img src="http://blog.jactionscripters.com/wp-content/uploads/2009/12/rotationTest_100.gif" alt="Rotating an instance 100 degrees" title="Rotating an instance 100 degrees" width="270" height="235" class="alignnone size-full wp-image-1035" /></p>
<p>The following code reveals the reason.</p>
<blockquote><p>0 80.00003182368921 0<br />
Vector3D(0, 1.3962639570236206, 0)<br />
180.00000500895632 80.00003182368921 180.00000500895632<br />
Vector3D(3.1415927410125732, 1.3962639570236206, 3.1415927410125732)</p></blockquote>
<p><code-style></p>
<pre name="code" class="as3">
var mySprite:Sprite = new Sprite();
var axis:Vector3D = Vector3D.Y_AXIS;  // Vector3D.X_AXIS  // Try to change this
mySprite.rotationY = 0;
var myMatrix3D:Matrix3D = mySprite.transform.matrix3D;
myMatrix3D.prependRotation(80, axis);
xTrace(mySprite);
myMatrix3D.prependRotation(20, axis);
xTrace(mySprite);
function xTrace(targetSprite:Sprite):void {
	trace(targetSprite.rotationX, targetSprite.rotationY, targetSprite.rotationZ);
	trace(targetSprite.transform.matrix3D.decompose()[1]);
}
</pre>
<p></code></p>
<p>When the <em>Matrix3D.prependRotation()</em> method rotates an instance 100 degrees with y axis, it is only rotated 80 degrees but is flipped with x and z axes.</p>
<p>The appearance of the instance is all right. But the number of degrees is not good. Besides, 100 degrees can be set with x or z axis. It means that the result of y axis is not consistent. Therefore, I suspect that this is a bug.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/12/05/rotating-an-instance-with-the-y-axis/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Three types of transformation objects in the Transform class</title>
		<link>http://blog.jactionscripters.com/2009/10/14/three-types-of-transformation-objects-in-the-transform-class/</link>
		<comments>http://blog.jactionscripters.com/2009/10/14/three-types-of-transformation-objects-in-the-transform-class/#comments</comments>
		<pubDate>Wed, 14 Oct 2009 09:25:07 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=985</guid>
		<description><![CDATA[The Transform class has several kinds of transformation objects as its properties.
The Transform class provides access to color adjustment properties and two- or three-dimensional transformation objects that can be applied to a display object.
I noticed three types of properties from the point of view of getting and seting their values.
The first example is the Transform.matrix [...]]]></description>
			<content:encoded><![CDATA[<p>The Transform class has several kinds of transformation objects as its properties.</p>
<blockquote><p>The Transform class provides access to color adjustment properties and two- or three-dimensional transformation objects that can be applied to a display object.</p></blockquote>
<p>I noticed three types of properties from the point of view of getting and seting their values.</p>
<p>The first example is the <em>Transform.matrix</em> property.  It does not provide its Matrix object reference but its copy.  It means that operations to the copy will not affect to the property&#8217;s Matrix object.  To set a Matrix object to the <em>Transform.matrix</em> property, the object should be assigned to the property.</p>
<p><code-style></p>
<pre name="code" class="as3">var mySprite:Sprite = new Sprite();
var myMatrix:Matrix = new Matrix();
mySprite.transform.matrix = myMatrix;
myMatrix.translate(100, 50);
trace(mySprite.transform.matrix);
// Output: (a=1, b=0, c=0, d=1, tx=0, ty=0)
mySprite.transform.matrix = myMatrix;
trace(mySprite.transform.matrix);
// Output: (a=1, b=0, c=0, d=1, tx=100, ty=50)
myMatrix = mySprite.transform.matrix;
myMatrix.scale(2, 1.5);
trace(mySprite.transform.matrix);
// Output: (a=1, b=0, c=0, d=1, tx=100, ty=50)
trace(mySprite.transform.matrix == myMatrix);  // Output: false</pre>
<p></code></p>
<p>The second example is the <em>Transform.matrix3D</em> property.  Unlike to the <em>Transform.matrix</em> property, a Matrix3D object&#8217;s reference is obtained from the property.    Therefore, once its reference is gotten, operations to the reference affects to the <em>Transform.matrix3D</em> property.</p>
<p><code-style></p>
<pre name="code" class="as3">var mySprite:Sprite = new Sprite();
var myMatrix3D:Matrix3D = new Matrix3D();
mySprite.transform.matrix3D = myMatrix3D;
myMatrix3D.prependTranslation(100, 50, 0);
trace(mySprite.transform.matrix3D.position);
// Output: Vector3D(100, 50, 0)
trace(mySprite.transform.matrix3D == myMatrix3D);  // Output: true</pre>
<p></code></p>
<p>The third one is the <em>Transform.perspectiveProjection</em> property. When a new PerspectiveProjection instance is assigned to the property, operations to the instance do not affect to the property as well as the <em>Transform.matrix</em> property. Then, try to get the object from the property and set it to a variable again. You can operate the variable as if it was the object reference of the property. However the variable&#8217;s object is not evaluated to be equal to the property&#8217;s value. It is a mysterious property, isn&#8217;t it.</p>
<p><code-style></p>
<pre name="code" class="as3">var mySprite:Sprite = new Sprite();
var myPerspective:PerspectiveProjection = new PerspectiveProjection();
mySprite.transform.perspectiveProjection = myPerspective;
myPerspective.fieldOfView = 20;
trace(mySprite.transform.perspectiveProjection.fieldOfView);  // Output: 55
myPerspective = mySprite.transform.perspectiveProjection;
myPerspective.fieldOfView = 100;
trace(mySprite.transform.perspectiveProjection.fieldOfView);  // Output: 100
trace(mySprite.transform.perspectiveProjection == myPerspective);
// Output: false</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/10/14/three-types-of-transformation-objects-in-the-transform-class/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>&#8220;Private&#8221; classes might cause a compile error</title>
		<link>http://blog.jactionscripters.com/2009/09/08/private-classes-might-cause-a-compile-error/</link>
		<comments>http://blog.jactionscripters.com/2009/09/08/private-classes-might-cause-a-compile-error/#comments</comments>
		<pubDate>Tue, 08 Sep 2009 02:09: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=910</guid>
		<description><![CDATA[BeInteractive! (blog written by Yoshihiro Shindo) reported a bug of &#8220;private&#8221; classes (defined outside of the package block).  Two or more &#8220;private&#8221; classes might cause a compile error, which tells  that a local variable declared in a main class (inside the package) is undefined in Flash CS4 Professional.
1120: Access of undefined property s.
I [...]]]></description>
			<content:encoded><![CDATA[<p>BeInteractive! (blog written by <a href="http://blog.jactionscripters.com/author/beinteractive/" target="_blank">Yoshihiro Shindo</a>) reported <a href="http://www.be-interactive.org/index.php?itemid=434" target="_blank">a bug of &#8220;private&#8221; classes</a> (defined outside of the package block).  Two or more &#8220;private&#8221; classes might cause a <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/compilerErrors.html" target="_blank">compile error</a>, which tells  that a local variable declared in a main class (inside the package) is undefined in Flash CS4 Professional.</p>
<blockquote><p>1120: Access of undefined property s.</p></blockquote>
<div class="wp-caption alignnone" style="width: 515px"><img alt="Compile error #1120" src="http://www.fumiononaka.com/Drafts/wonderfl/wonderfl_images/02_01_OOP_and_Class_002.gif" title="Compile error #1120" width="505" height="395" /><p class="wp-caption-text">Compile error #1120</p></div>
<p>I found another condition of the error.  If a &#8220;private&#8221; class inherits a class other than Object the compile error will be prevented.</p>
<p><code-style></p>
<pre name="code" class="as3">package {
	import flash.display.Sprite;
	public class PrivateClassIssue extends Sprite {
		public function PrivateClassIssue() {
			var s:String = 'hello';
			trace(s);
		}
	}
}
class Foo {}
class Bar extends Array {}  // inherits Array class</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/09/08/private-classes-might-cause-a-compile-error/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Calculation of focalLength</title>
		<link>http://blog.jactionscripters.com/2009/09/06/calculation-of-focallength/</link>
		<comments>http://blog.jactionscripters.com/2009/09/06/calculation-of-focallength/#comments</comments>
		<pubDate>Sun, 06 Sep 2009 13:44:41 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=861</guid>
		<description><![CDATA[[Help] of PerspectiveProjection.focalLength property says:
During the perspective transformation, the focalLength is calculated dynamically using the angle of the field of view and the stage&#8217;s aspect ratio (stage width divided by stage height).
However as far as I tested it, the stage height does not affect the result of focalLength property&#8217;s value.  It is calculated from [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/PerspectiveProjection.html#focalLength" target="_blank">[Help] of <em>PerspectiveProjection.focalLength</em> property</a> says:</p>
<blockquote><p>During the perspective transformation, the focalLength is calculated dynamically using the angle of the field of view and the stage&#8217;s aspect ratio (stage width divided by stage height).</p></blockquote>
<p>However as far as I tested it, the stage height does not affect the result of focalLength property&#8217;s value.  It is calculated from only the stage width by the following formula:</p>
<blockquote><p>tan(fieldOfView/2) = (stageWidth/2)/focalLength<br />
focalLength = stageWidth/2 tan(fieldOfView/2)</p></blockquote>
<p><img src="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/images/frustum.jpg" alt="From [Help] of PerspectiveProjection" /><br />
*From <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/geom/PerspectiveProjection.html" target="_blank">[Help] of PerspectiveProjection</a><br />
<div id="attachment_885" class="wp-caption alignnone" style="width: 444px"><img src="http://blog.jactionscripters.com/wp-content/uploads/2009/09/focallength.gif" alt="focal length and field of view" title="focal length and field of view" width="434" height="218" class="size-full wp-image-885" /><p class="wp-caption-text">focal length and field of view</p></div></p>
<p>Therefore the function below returns focal length by passing field of view.</p>
<p><code-style></p>
<pre name="code" class="as3">// Frame action
function getFocalLength(nFieldOfView:Number):Number {
	var falf_tan:Number = Math.tan(nFieldOfView / 2 * Math.PI / 180);
	return stage.stageWidth/2/falf_tan;
}</pre>
<p></code></p>
<hr width="100">
<p>[Note]: With <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/flash/display/Stage.html#scaleMode" target="_blank">Stage.scaleMode property</a> set to <em>StageScaleMode.NO_SCALE</em>, the value of <em>Stage.stageWidth</em> property can be changed when the browser window is resized.  However the <em>PerspectiveProjection.focalLength</em> would be calculated by the original width of the stage set with the [Property] inspector.</p>
<p>The revised function below can return the right result in the case:</p>
<p><code-style></p>
<pre name="code" class="as3">// Frame action
var originalMode:String = stage.scaleMode;
stage.scaleMode = StageScaleMode.EXACT_FIT;
var myStageWidth:int = stage.stageWidth;
stage.scaleMode = originalMode;
function getFocalLength(nFieldOfView:Number):Number {
	var falf_tan:Number = Math.tan(nFieldOfView / 2 * Math.PI / 180);
	// return stage.stageWidth/2/falf_tan;
	return myStageWidth/2/falf_tan;
}</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/09/06/calculation-of-focallength/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Setting String to DataGridColumn.cellRenderer property</title>
		<link>http://blog.jactionscripters.com/2009/08/10/setting-string-to-datagridcolumncellrenderer-property/</link>
		<comments>http://blog.jactionscripters.com/2009/08/10/setting-string-to-datagridcolumncellrenderer-property/#comments</comments>
		<pubDate>Mon, 10 Aug 2009 13:58:30 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=822</guid>
		<description><![CDATA[Reference of a class to render the items in a column can be set to DataGridColumn.cellRenderer property as the following frame action:

// Frame action
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
var myColmn:DataGridColumn = new DataGridColumn("data");
var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(myColmn);
// myColmn.cellRenderer = "CustomCellRenderer";  // Error #2007
myColmn.cellRenderer = CustomCellRenderer;  // OK
myDataGrid.addItem({data: "test"});
addChild(myDataGrid);

[Help] also tells that the type of the property&#8217;s [...]]]></description>
			<content:encoded><![CDATA[<p>Reference of a class to render the items in a column can be set to <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/controls/dataGridClasses/DataGridColumn.html#cellRenderer" target="_blank"><em>DataGridColumn.cellRenderer</em> property</a> as the following frame action:</p>
<p><code-style></p>
<pre name="code" class="as3">// Frame action
import fl.controls.DataGrid;
import fl.controls.dataGridClasses.DataGridColumn;
var myColmn:DataGridColumn = new DataGridColumn("data");
var myDataGrid:DataGrid = new DataGrid();
myDataGrid.addColumn(myColmn);
// myColmn.cellRenderer = "CustomCellRenderer";  // Error #2007
myColmn.cellRenderer = CustomCellRenderer;  // OK
myDataGrid.addItem({data: "test"});
addChild(myDataGrid);</pre>
<p></code></p>
<p>[Help] also tells that the type of the property&#8217;s value can be String. However setting a String class name causes Error #2007 like the below. The error would be shown if the comment-outed statement was validated instead in the sample above.</p>
<blockquote><p>TypeError:Error #2007:Parameter child must be non-null.</p></blockquote>
<p>I happened to see <a href="http://help.adobe.com/en_US/AS2LCR/Flash_10.0/00002146.html#3142008" target="_blank"><em>DataGridColumn.cellRenderer</em> property</a> in ActionScript 2.0 Components Language Reference.  It says that the property is &#8220;a linkage identifier for a symbol&#8221;.</p>
<p>Therefore, I tried to create an empty MovieClip symbol and to <a href="http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b8ea63-7fee.html" target="_balnk">set the class to [Class] of [Linkage]</a>. Then the String class name set to the property in the code above worked properly without an error. As my conclusion, a String class name might only be used for the class set to [Class] of [Linkage].</p>
<p><img src="http://www.fumiononaka.com/TechNotes/Images/FN0908002_001.gif" alt="Symbol Properties" /></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/08/10/setting-string-to-datagridcolumncellrenderer-property/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Resizing the drop down list of ComboBox when removeItem() is called</title>
		<link>http://blog.jactionscripters.com/2009/07/28/resizing-the-drop-down-list-of-combobox-when-removeitem-is-called/</link>
		<comments>http://blog.jactionscripters.com/2009/07/28/resizing-the-drop-down-list-of-combobox-when-removeitem-is-called/#comments</comments>
		<pubDate>Tue, 28 Jul 2009 13:21:04 +0000</pubDate>
		<dc:creator>Fumio Nonaka</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=785</guid>
		<description><![CDATA[When items in a CombBox compnent instance are removed with ComboBox.removeItem() method, its size of drop down list will not be adjusted.  I suspect that this behavior might be a bug because ComboBox.removeItemAt() method properly reset its size.
 -> 
In order to set size of the drop down list properly call UIComponent.validateNow() method after [...]]]></description>
			<content:encoded><![CDATA[<p>When items in a CombBox compnent instance are removed with <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/controls/ComboBox.html#removeItem()" target="_blank">ComboBox.removeItem() method</a>, its size of drop down list will not be adjusted.  I suspect that this behavior might be a bug because ComboBox.removeItemAt() method properly reset its size.</p>
<p><img src="http://blog.jactionscripters.com/wp-content/uploads/2009/07/combobox_removeitem_0011.gif" alt="Combobox.removeItem()" title="Combobox.removeItem()" width="100" height="82" class="alignnone size-full wp-image-788" /> -> <img src="http://blog.jactionscripters.com/wp-content/uploads/2009/07/combobox_removeitem_002.gif" alt="Combobox.removeitem()" title="Combobox.removeitem()" width="100" height="82" class="alignnone size-full wp-image-792" /></p>
<p>In order to set size of the drop down list properly call <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/core/UIComponent.html#validateNow()" target="_blank">UIComponent.validateNow() method</a> after an item is removed with the method like the following code:</p>
<p><code-style></p>
<pre name="code" class="as3">// Frame action
import fl.controls.ComboBox;
var myComboBox:ComboBox = new ComboBox();
addChild(myComboBox);
myComboBox.addEventListener(Event.CHANGE, xSelected);
myComboBox.addItem({label:"Dreamweaver CS4", data:"html"});
myComboBox.addItem({label:"Fireworks CS4", data:"png"});
myComboBox.addItem({label:"Flash CS4 Professional", data:"fla"});
function xSelected(eventObject:Event):void {
	var myItem:Object = myComboBox.getItemAt(0);
	myComboBox.removeItem(myItem);
	myComboBox.validateNow();  // Insert this statement.
}</pre>
<p></code></p>
<p>In the ComboBox class ComboBox.removeItemAt() method calls <a href="http://help.adobe.com/en_US/AS3LCR/Flash_10.0/fl/core/UIComponent.html#invalidate()" target="?blank">UIComponent.invalidate() method</a> after deleting an item with List.removeItemAt() method.</p>
<p><code-style></p>
<pre name="code" class="as3">public function removeItemAt(index:uint):void {
	list.removeItemAt(index);
	invalidate(InvalidationType.DATA);
}</pre>
<p></code></p>
<p>However, ComboBox.removeItem() method does not call the method.</p>
<p><code-style></p>
<pre name="code" class="as3">public function removeItem(item:Object):Object {
	return list.removeItem(item);
}</pre>
<p></code></p>
<p>Therefore, UIComponent.invalidate() method could be used instead of UIComponent.validateNow() method.</p>
<p><code-style></p>
<pre name="code" class="as3">// Frame action
import fl.core.InvalidationType;
import fl.controls.ComboBox;
var myComboBox:ComboBox = new ComboBox();
addChild(myComboBox);
myComboBox.addEventListener(Event.CHANGE, xSelected);
myComboBox.addItem({label:"Dreamweaver CS4", data:"html"});
myComboBox.addItem({label:"Fireworks CS4", data:"png"});
myComboBox.addItem({label:"Flash CS4 Professional", data:"fla"});
function xSelected(eventObject:Event):void {
	var myItem:Object = myComboBox.getItemAt(0);
	myComboBox.removeItem(myItem);
	myComboBox.invalidate(InvalidationType.DATA);  // Insert this statement.
}</pre>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/07/28/resizing-the-drop-down-list-of-combobox-when-removeitem-is-called/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Particle Storm demo &amp; source</title>
		<link>http://blog.jactionscripters.com/2009/06/23/particle-storm-demo-source/</link>
		<comments>http://blog.jactionscripters.com/2009/06/23/particle-storm-demo-source/#comments</comments>
		<pubDate>Mon, 22 Jun 2009 15:41:12 +0000</pubDate>
		<dc:creator>Takayuki Fukatsu</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[VisualSketch]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=736</guid>
		<description><![CDATA[FITC: Cool Japan side A / Particle sample of SMOKE &#8211; wonderfl build flash online
I think I have forgotton to post this experiment to JActionScripters.
Here is a playable demo &#038; source code that I showed on the FITC2009 session. Storm simulation with 10000 particle.
Basically all physic and mouse interaction is calculated with bitmap force map. [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align:center;width:465px;"><iframe title="FITC: Cool Japan side A / Particle sample of SMOKE - wonderfl build flash online" src="http://wonderfl.net/blogparts/e5458ebf7b16817e3529321415c4f17ce965515a" width="465" height="490" style="border:1px black solid;"></iframe><a href="http://wonderfl.net/code/e5458ebf7b16817e3529321415c4f17ce965515a" title="FITC: Cool Japan side A / Particle sample of SMOKE - wonderfl build flash online">FITC: Cool Japan side A / Particle sample of SMOKE &#8211; wonderfl build flash online</a></div>
<p>I think I have forgotton to post this experiment to JActionScripters.<br />
Here is a <a href="http://wonderfl.net/code/e5458ebf7b16817e3529321415c4f17ce965515a">playable demo &#038; source</a> code that I showed on the FITC2009 session. Storm simulation with 10000 particle.</p>
<p>Basically all physic and mouse interaction is calculated with bitmap force map. Precalculating mouse interaction with bitmap is much faster than doing mouse distance with 10000 particles every frame.</p>
<p>You can also see stupid <a href="http://wonderfl.net/code/0108d7b3b7a336aa406134e62ae6a50736519c08">250000 particle version</a> here.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/06/23/particle-storm-demo-source/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ARMessageCard (ARSandPainting)</title>
		<link>http://blog.jactionscripters.com/2009/06/02/armessagecard-arsandpainting/</link>
		<comments>http://blog.jactionscripters.com/2009/06/02/armessagecard-arsandpainting/#comments</comments>
		<pubDate>Tue, 02 Jun 2009 07:06:01 +0000</pubDate>
		<dc:creator>Yoshihiro Shindo</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Experiment]]></category>
		<category><![CDATA[Showcase]]></category>

		<guid isPermaLink="false">http://blog.jactionscripters.com/?p=730</guid>
		<description><![CDATA[
In the Spark meeting #09, I presented an ARMessageCard for Geoff. At first, a card on the marker seems to be white, but a message will be rose by particles moves if you tilt the card. It works like a sand painting.

ARMessageCard from Yoshihiro Shindo on Vimeo.
You can try it at here (Please use this [...]]]></description>
			<content:encoded><![CDATA[<p><img src="http://blog.jactionscripters.com/wp-content/uploads/2009/05/armessagecard.png" alt="ARMessageCard" title="ARMessageCard" width="640" height="360" class="alignnone size-full wp-image-706" /></p>
<p>In <a href="http://blog.jactionscripters.com/2009/05/29/monthly-spark-meeting-09/">the Spark meeting #09</a>, I presented an ARMessageCard for Geoff. At first, a card on the marker seems to be white, but a message will be rose by particles moves if you tilt the card. It works like a sand painting.</p>
<p><object width="400" height="300"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=4901020&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=4901020&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="400" height="300"></embed></object>
<p><a href="http://vimeo.com/4901020">ARMessageCard</a> from <a href="http://vimeo.com/user1825548">Yoshihiro Shindo</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
<p>You can try it at <a href="http://www.be-interactive.org/works/20090528/ARMessageCard/ARMessageCard.swf">here</a> (Please use <a href="http://www.be-interactive.org/works/20090528/ARMessageCard/Data/flarlogo-marker.pdf">this marker</a>). Of course, <a href="http://www.be-interactive.org/works/20090528/ARMessageCard.zip">source code was uploaded</a>.</p>
<p>A point of this Flash is calculating gravity from the inclination of the card to move particles.</p>
<p>If you defined variables like:</p>
<p><code-style>
<pre name="code" class="as3">
private var _mat:Matrix3D = new Matrix3D();
private var _rot:Number3D = Number3D.ZERO;
private var _v:Number3D = new Number3D();
</pre>
<p></code-style></p>
<p>*Matrix3D and Number3D are provided by Papervision3D.</p>
<p>You can get gravity by the following code:</p>
<p><code-style>
<pre name="code" class="as3">
_mat.copy(_baseNode.transform);
_mat.invert();
_rot = Matrix3D.matrix2euler(_mat, _rot);
_v.reset(0, 1, 0);
_v.rotateY(_rot.y);
_v.rotateX(_rot.x);
_v.rotateZ(_rot.z);
var gx:Number = -_v.x * 2.0;
var gy:Number = -_v.y * 2.0;
</pre>
<p></code-style></p>
<p>*_baseNode is provided by FLARToolKit.</p>
<p>First, invert the transform matrix calculated by the FLARToolKit to get a transform matrix of gravity about the marker. Next, apply only rotations from the transform matrix to a normalized vector for gravity. Finally, get x value and y value from it. If you move particles based on these values, it will work fine <img src='http://blog.jactionscripters.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.jactionscripters.com/2009/06/02/armessagecard-arsandpainting/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
