<?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>Yahoo! Flash (R) Blog</title>
	<atom:link href="http://www.yswfblog.com/blog/index.php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.yswfblog.com/blog</link>
	<description>News and Articles on Yahoo! Flash Components and Libraries</description>
	<lastBuildDate>Tue, 30 Jun 2009 22:27:28 +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>Yes, Virginia, There is Compression in Flash</title>
		<link>http://www.yswfblog.com/blog/2009/06/30/compression-in-flash/</link>
		<comments>http://www.yswfblog.com/blog/2009/06/30/compression-in-flash/#comments</comments>
		<pubDate>Tue, 30 Jun 2009 22:27:28 +0000</pubDate>
		<dc:creator>Alaric Cole</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/?p=284</guid>
		<description><![CDATA[I&#8217;m in the process of developing a new hybrid component&#8211;a component which utilizes the Flash Player but via a JavaScript API&#8211;for YUI. This new component will take advantage of Flash&#8217;s native SharedObject functionality to store local data in a larger amount than is typically allowed by a cookie. By default this storage is up to [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m in the process of developing a new hybrid component&#8211;a component which utilizes the Flash Player but via a JavaScript API&#8211;for YUI. This new component will take advantage of Flash&#8217;s native SharedObject functionality to store local data in a larger amount than is typically allowed by a cookie. By default this storage is up to 100kb. However, I found a way to store nearly half a megabyte in this space.</p>
<p>No, I didn&#8217;t have to request the user to allow 512kb of storage on their machine. And there was no magic or hackery involved. That&#8217;s because the space I took up on the hard drive was less than 100kb. I just took advantage of a little known feature in the Flash Player, allowing compression of data.<br />
This feature is quietly tucked away inside of the ByteArray class&#8211;<code>ByteArray.compress()</code> and <code>ByteArray.decompress()</code>.</p>
<p>Taking what was a half meg of JSON data over-the-wire and putting it into a SharedObject (which stores in binary) resulted in a huge savings already, about 60%. But compressing that data before storage resulted in a total of 80% savings.</p>
<p>I&#8217;ve still got some performance testing to do, as for all compression one must sacrifice processor cycles for storage space. But I feel pretty confident this will remain in the release version. So, either take this idea and run with it, or wait a bit for the next YUI release.</p>
<p>By the way, I also recently posted an article on the <a href="http://www.yuiblog.com">YUI Blog</a> entitled <a title="Permanent Link to Flash SOL: Persistent Data with Local SharedObjects" rel="bookmark" href="http://www.yuiblog.com/blog/2009/06/23/flash-sol/">Flash SOL: Persistent Data with Local SharedObjects</a>. Thought I&#8217;d share it with you all, if you didn&#8217;t see it.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2009/06/30/compression-in-flash/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Knack to Rotating Device Fonts in Flash 10</title>
		<link>http://www.yswfblog.com/blog/2009/05/21/the-knack-to-rotating-dynamic-text-in-flash-10/</link>
		<comments>http://www.yswfblog.com/blog/2009/05/21/the-knack-to-rotating-dynamic-text-in-flash-10/#comments</comments>
		<pubDate>Thu, 21 May 2009 13:00:33 +0000</pubDate>
		<dc:creator>Allen Rabinovich</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[device fonts]]></category>
		<category><![CDATA[dynamic text]]></category>
		<category><![CDATA[Flash 10]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/?p=245</guid>
		<description><![CDATA[ In Flash Player 10, Adobe developers added a great new feature: the ability to rotate dynamic text generated using device fonts already present on the user&#8217;s machine, not the fonts embedded in the SWF. However, using this feature is a bit tricky, and we&#8217;ll describe two possible methods here.
Rotating device fonts is quite useful [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://us.js2.yimg.com/us.js.yimg.com/lib/flash/swfobject/1.0/swfobject.js" type="text/javascript"></script> In Flash Player 10, Adobe developers added a great new feature: the ability to rotate dynamic text generated using device fonts already present on the user&#8217;s machine, not the fonts embedded in the SWF. However, using this feature is a bit tricky, and we&#8217;ll describe two possible methods here.</p>
<p>Rotating device fonts is quite useful in many applications (as labels on a <a href="http://developer.yahoo.com/yui/charts" target="_blank">Chart</a>, for example), and not embedding the fonts is essential to keeping the SWFs small and taking advantage of the internationalization already built into the user&#8217;s system.  In previous versions of the Flash player, rotating dynamic text was only possible if the <strong><code>Sprite</code></strong> containing a dynamic <strong><code>TextField</code></strong> was first copied into a <strong><code>Bitmap</code></strong> object, and then rotated. This somewhat &#8220;hacky&#8221; approach produced results, albeit not very visually pleasing ones.</p>
<p>In the new Flash player, the new feature is not as simple as modifying the <strong><code>TextField.rotation</code></strong> property — if you set <strong><code>rotation</code></strong> of a TextField to anything other than 0, your text will disappear, just as in previous versions of the player. Instead, there are two new methods of producing rotated text — let&#8217;s look at both of them, and then discuss their advantages and disadvantages:</p>
<div id="TextRotation">The latest version of <a href="http://www.adobe.com/go/getflashplayer">Flash Player</a> is not installed or JavaScript is not enabled. Unable to display SWF content.</div>
<p><script type="text/javascript"><!--
var swfobj = new SWFObject( "http://www.yswfblog.com/blog/wp-content/uploads/2009/05/texttest.swf", "TextRotationOld", "530", "230", "10.0.0" );
swfobj.addParam("scale", "noscale");
swfobj.write( "TextRotation" );
// --></script></p>
<p><strong>The first method</strong>, used in the top row in the example above, simply modifies the <strong><code>rotationZ</code></strong> property of the <strong><code>TextField</code></strong>. This property, newly introduced in player 10, is generally used to rotate display objects in 3D space; however, rotation in Z-plane is mathematically equivalent to the regular, flat rotation. In some sense, it behaves similarly to the &#8220;old&#8221; method of rotating dynamic text: it first caches text as a bitmap, and only then rotates it. You can ascertain its bitmap nature by simply zooming in on the SWF: you&#8217;ll see the obvious pixelation around the edges of the text.<br />
Depending on the <strong>end user&#8217;s</strong> platform (Windows, OS X or Linux), this method may actually produce better-looking results for small to medium font sizes. It&#8217;s also quite simple to use — there is only one property to modify.</p>
<p><strong>The second method</strong> (used for the bottom row) is using new native AS3 class, called <strong><code>TextBlock</code></strong>. Part of the new <strong><code>flash.text.engine</code></strong> package, <strong><code>TextBlock</code></strong> allows you to generate a special kind of <strong><code>DisplayObject</code></strong>, called <strong><code>TextLine</code></strong>, which can be subjected to all standard <strong><code>DisplayObject</code></strong> transformations.</p>
<p>This method is a bit more involved, because <strong><code>TextLines </code></strong>cannot be instantiated on their own — you have to use the factory within <strong><code>TextBlock</code></strong> to generate them. This method also behaves somewhat differently on different platforms. I have given it a cursory test on OS X and Windows XP, and it appears that on OS X, all but the smallest <strong><code>TextLines</code></strong> are anti-aliased properly. On Windows, however, some of the medium-size lines come out looking very jagged, whereas the smallest and largest font sizes are properly anti-aliased. Of course, another thing to note with this method is that it preserves font glyphs as vector objects: if you zoom in on the SWF, you&#8217;ll see that they remain sharp and anti-aliased.</p>
<p>There&#8217;s a lot more investigating to do with these two methods, but I hope this will be a good start for you. The code for the example is below.</p>
<p><span id="more-245"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;">package <span style="color: #66cc66;">&#123;</span>
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">Sprite</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextField</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #0066CC;">TextFormat</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #0066CC;">text</span>.<span style="color: #006600;">engine</span>.<span style="color: #66cc66;">*</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">class</span> TextTest <span style="color: #0066CC;">extends</span> Sprite <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> TextTest <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> i:<span style="color: #0066CC;">int</span> = <span style="color: #cc66cc;">0</span>; i <span style="color: #66cc66;">&amp;</span>lt;= <span style="color: #cc66cc;">20</span>; i++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> txt:<span style="color: #0066CC;">TextField</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextField</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	txt.<span style="color: #0066CC;">selectable</span> = <span style="color: #000000; font-weight: bold;">false</span>;
	txt.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">300</span>;
	txt.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">100</span>;
	txt.<span style="color: #0066CC;">text</span> = <span style="color: #ff0000;">&quot;Hello world!&quot;</span>;
	txt.<span style="color: #0066CC;">setTextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">TextFormat</span><span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Georgia&quot;</span>, <span style="color: #cc66cc;">2</span> + <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">*</span>i<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	txt.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>i<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>i+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
	txt.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">30</span>;
	txt.<span style="color: #006600;">rotationZ</span> = <span style="color: #cc66cc;">20</span>;
	addChild<span style="color: #66cc66;">&#40;</span>txt<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #b1b100;">for</span> <span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">var</span> j:<span style="color: #0066CC;">int</span>=<span style="color: #cc66cc;">0</span>; j<span style="color: #66cc66;">&amp;</span>lt;=<span style="color: #cc66cc;">20</span>; j++<span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #0066CC;">trace</span><span style="color: #66cc66;">&#40;</span>j<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> myString:<span style="color: #0066CC;">String</span> = <span style="color: #ff0000;">&quot;Hello world!&quot;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> myFormat:ElementFormat = <span style="color: #000000; font-weight: bold;">new</span> ElementFormat<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> myFontDesc:FontDescription = <span style="color: #000000; font-weight: bold;">new</span> FontDescription<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Georgia&quot;</span><span style="color: #66cc66;">&#41;</span>;
	myFormat.<span style="color: #006600;">fontSize</span> = <span style="color: #cc66cc;">2</span> + <span style="color: #cc66cc;">2</span><span style="color: #66cc66;">*</span>j;
	myFormat.<span style="color: #006600;">fontDescription</span> = myFontDesc; 
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> textElement:TextElement = <span style="color: #000000; font-weight: bold;">new</span> TextElement<span style="color: #66cc66;">&#40;</span>myString, myFormat<span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> textBlock:TextBlock = <span style="color: #000000; font-weight: bold;">new</span> TextBlock<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	textBlock.<span style="color: #006600;">content</span> = textElement; 
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> myTextLine:TextLine = textBlock.<span style="color: #006600;">createTextLine</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">null</span>, <span style="color: #cc66cc;">300</span><span style="color: #66cc66;">&#41;</span>; 
&nbsp;
	myTextLine.<span style="color: #006600;">x</span> = <span style="color: #cc66cc;">6</span><span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>j<span style="color: #66cc66;">*</span><span style="color: #66cc66;">&#40;</span>j+<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">/</span><span style="color: #cc66cc;">2</span><span style="color: #66cc66;">&#41;</span>;
	myTextLine.<span style="color: #006600;">y</span> = <span style="color: #cc66cc;">150</span>;
	myTextLine.<span style="color: #006600;">rotation</span> = <span style="color: #cc66cc;">20</span>;
&nbsp;
	addChild<span style="color: #66cc66;">&#40;</span>myTextLine<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
  <span style="color: #66cc66;">&#125;</span>
 <span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2009/05/21/the-knack-to-rotating-dynamic-text-in-flash-10/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>Astra Stimulus Package</title>
		<link>http://www.yswfblog.com/blog/2009/04/15/astra-14/</link>
		<comments>http://www.yswfblog.com/blog/2009/04/15/astra-14/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 20:39:59 +0000</pubDate>
		<dc:creator>Alaric Cole</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[accessibility]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/?p=230</guid>
		<description><![CDATA[We&#8217;re filing late this year but we were determined to get this thing in before midnight. We thought about asking for an extension, but decided the paperwork was too complicated. So here we go, crossing our fingers&#8230;
Astra 1.4 is now ready for direct deposit into your Flash or Flex applications.
New this season is a component [...]]]></description>
			<content:encoded><![CDATA[<p>We&#8217;re filing late this year but we were determined to get this thing in before midnight. We thought about asking for an extension, but decided the paperwork was too complicated. So here we go, crossing our fingers&#8230;</p>
<p>Astra 1.4 is now ready for direct deposit into your Flash or Flex applications.</p>
<p>New this season is a component called Form which will help with those gathering and validating data in Flash. Also notable to mention is that most of Astra is now accessible. We&#8217;ve added a section to each component on <a href="http://developer.yahoo.com/flash/">developer.yahoo.com/flash</a> speaking directly to those trying to get components to work with screen readers. There are also, as always, some nice bug fixes and new features. The full list follows:</p>
<h4>Flash</h4>
<ul>
<li>New Form component and form data manager utility</li>
<li>Carousel:
<ul>
<li>enhanced keyboard navigation</li>
<li>added accessibility</li>
<li>fixed bug: null reference error when setting multiple data providers</li>
</ul>
</li>
<li>Charts:
<ul>
<li>allow for negative values in stacked bar and column charts.</li>
<li>fixed bug in stacked bar and column charts in which markers were sized incorrectly for multiple series.</li>
<li>fixed bug in TimeAxis in which majorUnit was not being calculated correctly.</li>
<li>fixed bug in TimeAxis in which minorUnit was not being calculated.</li>
<li>fixed bug in which <code>hideOverlappingLabels</code> style did not work on the y-axis</li>
<li>refactored origin axes, <code>TimeAxis</code> and <code>NumericAxis</code>, to allow for factoring in the label size when calculating a <code>majorUnit</code>.</li>
<li>added option to <code>CategoryAxis</code> to allow for a more systematic dropping of labels when there is not enough space for all categories on the axis.</li>
<li>fixed bug in which null values break line series.</li>
<li>fixed bug in NumericAxis in which external data was not being casted as a Number.</li>
<li>allow option for rotating text when fonts are not embedded.</li>
<li>fixed bug in which Cartesian Charts, were not being updated when the length of the <code>dataSource</code> was different.</li>
<li>added enhanced styling of series by allowing the specification of fill, border and line color and alpha styles.</li>
<li>added option of styling a highlighted zero gridline when the zero is beyond the origin of a <code>NumericAxis</code>.</li>
</ul>
</li>
<li>Menu:
<ul>
<li>enhanced keyboard navigation</li>
<li>fixed bug in labelField property</li>
<li>added support for non-XML data providers</li>
<li>added beta accessibility implementation</li>
<li>fixed bug where focusing out would not close menus</li>
</ul>
</li>
<li>MenuBar:
<ul>
<li>enhanced keyboard navigation</li>
<li>added beta accessibility implementation</li>
<li>added support for non-XML data providers</li>
<li>added labelField property</li>
<li>added support for disabled menu bar items</li>
</ul>
</li>
<li>Tree:
<ul>
<li>Fixed out-of-bounds index error that appeared under certain conditions.</li>
<li>improved keyboard navigation</li>
<li>added events for opening and closing of nodes</li>
<li>added accessibility implementation</li>
<li>added TreeEvent</li>
</ul>
</li>
<li>AlertManager:
<ul>
<li>fixed issue with keyboard focus on disabled controls</li>
<li>made some properties publicly accessible</li>
<li>added beta accessibility implementation</li>
</ul>
</li>
<li>AudioPlayback:
<ul>
<li>enhanced keyboard navigation &#8211; added keyboard support for volume control</li>
<li>made some properties publicly accessible</li>
<li>added accessibility implementations for subcontrols (volume, current track)</li>
</ul>
</li>
</ul>
<h4>Flex</h4>
<ul>
<li>AutoCompleteManager:
<ul>
<li>Added ability to retrieve specific popup instances and control them</li>
<li>Enhanced algorithm for target resizing and moving</li>
</ul>
</li>
<li>IPv4AddressInput, TimeInput, TimeStepper, DropdownColorPicker:
<ul>
<li>Added accessibility implementation</li>
</ul>
</li>
</ul>
<h4>Utils</h4>
<ul>
<li>Improved performance of layout for very large containers</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2009/04/15/astra-14/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Rocking it at SXSWi</title>
		<link>http://www.yswfblog.com/blog/2009/03/17/rocking-it-at-sxswi/</link>
		<comments>http://www.yswfblog.com/blog/2009/03/17/rocking-it-at-sxswi/#comments</comments>
		<pubDate>Tue, 17 Mar 2009 19:15:35 +0000</pubDate>
		<dc:creator>Alaric Cole</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/?p=226</guid>
		<description><![CDATA[The Flash Platform team is representing at South by Southwest in Austin. No, we&#8217;re not playing in a band this year, though I do hear Tripp is a hell of a guitar player. We&#8217;re focused on SXSWi, where all the cool kids congregate to showcase cutting edge technology in the interactive realm. More Rock Band® [...]]]></description>
			<content:encoded><![CDATA[<p>The Flash Platform team is representing at South by Southwest in Austin. No, we&#8217;re not playing in a band this year, though I do hear Tripp is a hell of a guitar player. We&#8217;re focused on SXSWi, where all the cool kids congregate to showcase cutting edge technology in the interactive realm. More Rock Band® than rock band.</p>
<p>I just finished speaking about accessibility in Flash and Flex applications. More accurately, I went over the steps to make components accessible, something the readers of this blog have heard me talk about at length. I demoed the usage of a screen reader, which, I was warned, was a dangerous endeavor. It went over pretty well, though, and I was able to show the difference between the the different bits of information you can send to a screen reader. Settling on the Astra Tree component, I added different properties to its accessibility implementation&#8211;such as Name, Value, State, and events&#8211;and discussed how each was important to make the component fully accessible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2009/03/17/rocking-it-at-sxswi/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Creating Accessible Components in Flash and Flex (Part 2)</title>
		<link>http://www.yswfblog.com/blog/2009/01/12/creating-accessible-components-in-flash-and-flex-part-2/</link>
		<comments>http://www.yswfblog.com/blog/2009/01/12/creating-accessible-components-in-flash-and-flex-part-2/#comments</comments>
		<pubDate>Mon, 12 Jan 2009 13:54:33 +0000</pubDate>
		<dc:creator>Alaric Cole</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[accessibility]]></category>
		<category><![CDATA[screen reader]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/?p=114</guid>
		<description><![CDATA[In this article, I&#8217;ll go over the steps needed to enable accessibility for a custom component. While it takes a bit of getting used to, I think you&#8217;ll find that enabling accessibility for your components is not only beneficial to the many users who would like to interact with your component, but helps you to [...]]]></description>
			<content:encoded><![CDATA[<p>In this article, I&#8217;ll go over the steps needed to enable accessibility for a custom component. While it takes a bit of getting used to, I think you&#8217;ll find that enabling accessibility for your components is not only beneficial to the many users who would like to interact with your component, but helps you to fine-tune and further enhance your components in general. To enable use with screen readers, follow these three (simple?) steps:</p>
<ol>
<li>Determine object role</li>
<li>Create the Accessibility Implementation class for component</li>
<li>Add accessibility tie-ins to component class<br />
a) Create a placeholder for the static <code>createAccessibilityImplementation()</code> method<br />
b) Override <code>initializeAccessibility()</code> method<br />
c) (Flex only) Add AccessibilityClass metadata</li>
</ol>
<p><span id="more-114"></span></p>
<h3>Determine object role</h3>
<p>In order for the JAWS screen reader to inform the user about a particular component, it needs to know a few things about the component. Most importantly, it needs to know what the type of the component is. It does this using a predefined set of types, called <a href="http://msdn.microsoft.com/en-us/library/ms696152(VS.85).aspx" target="_blank">Object Roles</a> in <a href="http://msdn.microsoft.com/en-us/library/ms697707(VS.85).aspx" target="_blank">MSAA</a> terminology. These object roles are simply numerical values, standing for control types such as push buttons and list boxes. I like to define them as constants in my accessibility implementations, to make them more identifiable. So the first step is determining the type, which also allows you to see if you need to extend a current accessibility implementation, or start from scratch. The second step is to actually create the implementation (*whew*).</p>
<h3>Create the Accessibility Implementation class</h3>
<p>To create an accessibility implementation, you need to extend from a base implementation class. For Flash components this will extend fl.accessibility.AccImpl or the component’s superclass’s implementation. For Flex components this will extend <code>mx.accessibility.AccImpl</code> or the component’s superclass’s implementation. For instance, with Astra Carousel, I extended <code>fl.accessibilitySelectableListAccImpl</code>, the implementation used for SelectableList; for Astra Charts, I created an implementation from scratch, extending <code>fl.accessibility.AccImpl</code>.</p>
<p>Generally, you can pair the superclass of your implementation with the component&#8217;s superclass. And if one&#8217;s not available, start at AccImpl. The main thing to remember is that, for Flash CS3/CS4 components, you need to create the hooks in your implementation that pair it up with its corresponding component. You do this by creating a static variable and a static method:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #6699cc; font-weight: bold;">var</span> accessibilityHooked<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>=hookAccessibility<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
&nbsp;
<span style="color: #0033ff; font-weight: bold;">private</span> static <span style="color: #339966; font-weight: bold;">function</span> hookAccessibility<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Boolean</span>
<span style="color: #000000;">&#123;</span>
     YourComponentClass.createAccessibilityImplementation =
          createAccessibilityImplementation;
     <span style="color: #0033ff; font-weight: bold;">return</span> <span style="color: #0033ff; font-weight: bold;">true</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>Notice in the hookAccessibility function, that it refers to a static variable of your component&#8217;s class. In order for this to work, you&#8217;ll need to add that static variable to your component&#8217;s class, which we&#8217;ll go over later in this article. Remember that the above code is for Flash CS3/CS4 components only&#8211;Flex will create the necessary hooks itself through the mxmlc compiler.</p>
<p>Once you&#8217;re hooked up, the next task is to actually set the object role you decided on. To do that, you simply set the variable role to that numerical value within the constructor of the implementation class.</p>
<p>Next is the hard part. All implementations will use the following methods to communicate with the screen reader, and you&#8217;ll find you need many of them to make your implementation work. However, you may not need to write custom code for all of them, as you may be able to inherit a perfectly usable method from the superclass:</p>
<p>• accLocation(childID:uint):* &#8211; specifies the bounding box of a child element.<br />
• accSelect(selFlag:uint, childID:uint):void-altering the selection in the component .<br />
• get_accDefaultAction(childID:uint):String-returns the default action of the component or of one of its child elements.<br />
• get_accFocus():uint-returns the unsigned integer ID of the child element, if any, that has child focus within the component.<br />
• get_accName(childID:uint):String-returns the name for the component or for one of its child elements.<br />
• get_accRole(childID:uint):uint-returns the system role for the component or for one of its child elements.<br />
• get_accSelection():Array-returns an array containing the IDs of all child elements that are selected.<br />
• get_accState(childID:uint):uint-returns the current runtime state of the component or of one of its child elements.<br />
• get_accValue(childID:uint):String-returns the runtime value of the component or of one of its child elements.<br />
• getChildIDArray():Array-returns an array containing the unsigned integer IDs of all child elements in the <span>AccessibilityImplementation</span>.<br />
• eventHandler(event:Event):void-Handles events from the master component. This essentially listens for events, and the developer must create a switch statement to call an Accessibility.sendEvent with the appropriate parameters.<br />
• getName(childID:uint):String-returns the name of the accessible component or the name of one of its child elements.<br />
• getState(childID:uint):uint-returns the state of the accessible component.</p>
<p>It’s important to note that there may be a number of other methods that need to be created for such things as telling the screenreader which child items are focused or what items are selected. Read on for some real-world examples of creating these.</p>
<h3>Add accessibility tie-ins to component class</h3>
<p>The last step is telling your component class to use this accessibility implementation. Actually, this is a step you can do on your components before you finalize your implementation class, because it doesn&#8217;t point to the accessibility class by name. Add these few lines of code to your class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #0033ff; font-weight: bold;">public</span> static <span style="color: #6699cc; font-weight: bold;">var</span> createAccessibilityImplementation<span style="color: #000000; font-weight: bold;">:</span><span style="color: #004993;">Function</span>;
&nbsp;
override <span style="color: #0033ff; font-weight: bold;">protected</span> <span style="color: #339966; font-weight: bold;">function</span> initializeAccessibility<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #000000; font-weight: bold;">:</span><span style="color: #0033ff; font-weight: bold;">void</span>
<span style="color: #000000;">&#123;</span>
     <span style="color: #0033ff; font-weight: bold;">if</span> <span style="color: #000000;">&#40;</span>YourComponentClass.createAccessibilityImplementation<span style="color: #000000; font-weight: bold;">!</span>=<span style="color: #0033ff; font-weight: bold;">null</span><span style="color: #000000;">&#41;</span>
          YourComponentClass.createAccessibilityImplementation<span style="color: #000000;">&#40;</span><span style="color: #0033ff; font-weight: bold;">this</span><span style="color: #000000;">&#41;</span>;
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>This tells UIComponent that there may be an implementation in use, and lets your implementation class mix in with its <code>hookAccessibility()</code> method. If you&#8217;re using Flex, it&#8217;s a good idea to add AccessibilityClass metadata in your component class. For example, with <code>mx.controls.Button</code>, the following metadata is added, pointing to the implementation class:</p>

<div class="wp_syntax"><div class="code"><pre class="actionscript3" style="font-family:monospace;"><span style="color: #000000;">&#91;</span>AccessibilityClass<span style="color: #000000;">&#40;</span>implementation=<span style="color: #990000;">&quot;mx.accessibility.ButtonAccImpl&quot;</span><span style="color: #000000;">&#41;</span><span style="color: #000000;">&#93;</span></pre></div></div>

<h3>Examples</h3>
<p>Talking about what you should do is one thing, but giving you a play-by-play of my own development experience should prove more helpful.</p>
<h4>Carousel</h4>
<p>To create an accessibility implementation for Carousel, I determined that, because Carousel extends <span>SelectableList</span>, my accessibility implementation would extend <span>SelectableListAccImpl</span>. This saved some of the grunt work, as a few of the necessary methods were already created for me. Even the role did not need to be set, as there is no specific designation for a carousel in MSAA. Carousel is essentially a list, so I was able to keep its role as <code>ROLE_SYSTEM_LIST</code> (0&#215;00000021 for the numerically-inclined). I did have to override the <code>get_accValue</code> method to return the value of the current item in the Carousel. Also, because a Carousel can be horizontal as well as vertical, I had to override <code>get_accState</code> to return the proper state information whether the Carousel was a vertical or horizontal list.</p>
<h4>Tree</h4>
<p>For Tree, I at first decided to create an accessibility implementation from scratch, probably because I was being stubborn. While Tree extends List, the typical ListAccImple class wasn&#8217;t going to cut it for Tree, which has a very different interaction model. However, I later realized that had to reimplement <code>getChildIDArray</code>, <code>accLocation</code>, and <code>get_accFocus</code>, which were already present and suitable in <span>SelectableListAccImpl</span>. So I decided in the end to extend that. However, there was a lot left to be written for this implementation. Tree, while it inherits from List, has its own designation in MSAA land. It is called, interestingly enough, an Outline control, designated by the constant <code>ROLE_SYSTEM_OUTLINE</code>. So that was the role I gave it. I reworked the <code>get_accValue</code> method to return the value of the current item as well as their location in the tree structure. So when the item is selected, the screen reader will read something like &#8220;Item 4 of 10&#8243;. Other things I had to do with Tree:</p>
<ul>
<li><code>get_accState</code> was overridden to provide additional information about tree items being collapsed or open.</li>
<li><code>get_accDefaultAction</code> had to show additional actions of a node being collapsed or expanded.</li>
<li><code>accDoDefaultAction</code> needed to be reworked in order to open or close the items.</li>
<li><code>getName</code> was overridden to add, like <code>get_accValue</code>, info about the current location of the item in the tree structure.</li>
</ul>
<p>I also found in my development that proper keyboard navigation wasn&#8217;t in place. So I added that in. That&#8217;s the great part about creating these implementations&#8211;it allows you to really test the usability of the component, not to mention helps you to find bugs.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2009/01/12/creating-accessible-components-in-flash-and-flex-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Flash 10 Experiments: The Warholizer (Loading and Processing Local Images)</title>
		<link>http://www.yswfblog.com/blog/2008/12/22/flash-10-experiments-the-warholizer-loading-and-processing-local-images/</link>
		<comments>http://www.yswfblog.com/blog/2008/12/22/flash-10-experiments-the-warholizer-loading-and-processing-local-images/#comments</comments>
		<pubDate>Mon, 22 Dec 2008 18:21:44 +0000</pubDate>
		<dc:creator>Allen Rabinovich</dc:creator>
				<category><![CDATA[Examples]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Flash 10]]></category>
		<category><![CDATA[Local Images]]></category>
		<category><![CDATA[Warholizer]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/?p=97</guid>
		<description><![CDATA[One of the new features in Flash Player 10 is the ability to read local files. We&#8217;ve been looking at this feature for some of our upcoming components, and built a small example that demonstrates how to load, display, and process local images.  This example, dubbed &#8220;The Warholizer&#8221;, allows you to open any image file [...]]]></description>
			<content:encoded><![CDATA[<p>One of the new features in Flash Player 10 is the ability to read local files. We&#8217;ve been looking at this feature for some of our upcoming components, and built a small example that demonstrates how to load, display, and process local images.  This example, dubbed &#8220;The Warholizer&#8221;, allows you to open any image file on your machine, and without uploading it to the server, extract the image&#8217;s bitmap data, and run it through some color filters, achieving an effect not unlike the one in some of Andy Warhol&#8217;s work. Try it out by dropping in a photo of your own for those 15 minutes of fame (though make sure the image is not too large: Flash has an upper limit on the size of bitmaps):</p>
<p><script src="http://us.js2.yimg.com/us.js.yimg.com/lib/flash/swfobject/1.0/swfobject.js" type="text/javascript"></script></p>
<div id="ImageLoaderDemo">Note: The proper version of <a href="http://www.adobe.com/go/getflashplayer">Flash Player</a> is not installed or JavaScript is not enabled. Unable to display SWF content.</div>
<p><script type="text/javascript"><!--
 var swfobj = new SWFObject( "http://www.yswfblog.com/blog/wp-content/uploads/2008/12/imageloader.swf", "ImageLoaderDemo", "100%", "500", "10.0.0" ); 
swfobj.write( "ImageLoaderDemo" ); 
// --></script></p>
<p>The code for the example is below the fold.</p>
<p><span id="more-97"></span></p>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&lt;</span>?<span style="color: #0066CC;">xml</span> <span style="color: #0066CC;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> encoding=<span style="color: #ff0000;">&quot;utf-8&quot;</span>?<span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:Application xmlns:mx=<span style="color: #ff0000;">&quot;http://www.adobe.com/2006/mxml&quot;</span> layout=<span style="color: #ff0000;">&quot;absolute&quot;</span> initialize=<span style="color: #ff0000;">&quot;init();&quot;</span> xmlns:ns1=<span style="color: #ff0000;">&quot;com.yahoo.astra.mx.controls.*&quot;</span><span style="color: #66cc66;">&gt;</span>
&nbsp;
<span style="color: #66cc66;">&lt;</span>mx:Script<span style="color: #66cc66;">&gt;</span>
	<span style="color: #66cc66;">&lt;!</span><span style="color: #66cc66;">&#91;</span>CDATA<span style="color: #66cc66;">&#91;</span>
&nbsp;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">Container</span>;
<span style="color: #0066CC;">import</span> mx.<span style="color: #006600;">core</span>.<span style="color: #006600;">UIComponent</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">net</span>.<span style="color: #006600;">FileReference</span>;
<span style="color: #0066CC;">import</span> flash.<span style="color: #006600;">display</span>.<span style="color: #006600;">BitmapData</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> fileRef:FileReference = <span style="color: #000000; font-weight: bold;">new</span> FileReference<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> init<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	fileRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">SELECT</span>, handleSelectedImage<span style="color: #66cc66;">&#41;</span>;
	fileRef.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, handleFileLoad<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> handleBrowseClick <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> typeFilter:<span style="color: #0066CC;">Array</span> = <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #0066CC;">Array</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	typeFilter.<span style="color: #0066CC;">push</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> FileFilter<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;Images&quot;</span>, <span style="color: #ff0000;">&quot;*.jpg;*.gif;*.png&quot;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	fileRef.<span style="color: #006600;">browse</span><span style="color: #66cc66;">&#40;</span>typeFilter<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> handleSelectedImage<span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	fileName.<span style="color: #0066CC;">text</span> = fileRef.<span style="color: #0066CC;">name</span>;
	fileRef.<span style="color: #0066CC;">load</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> handleFileLoad <span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> fileByteData:ByteArray = <span style="color: #000000; font-weight: bold;">new</span> ByteArray<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	fileByteData = fileRef.<span style="color: #0066CC;">data</span> as ByteArray;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> loader:Loader = <span style="color: #000000; font-weight: bold;">new</span> Loader<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	loader.<span style="color: #006600;">contentLoaderInfo</span>.<span style="color: #006600;">addEventListener</span><span style="color: #66cc66;">&#40;</span>Event.<span style="color: #006600;">COMPLETE</span>, extractBitmapData<span style="color: #66cc66;">&#41;</span>;
	loader.<span style="color: #006600;">loadBytes</span><span style="color: #66cc66;">&#40;</span>fileByteData<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> extractBitmapData <span style="color: #66cc66;">&#40;</span>evt:Event<span style="color: #66cc66;">&#41;</span> : <span style="color: #0066CC;">void</span> <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> sourceBMP:Bitmap = evt.<span style="color: #006600;">currentTarget</span>.<span style="color: #006600;">loader</span>.<span style="color: #006600;">content</span> as Bitmap;
	<span style="color: #000000; font-weight: bold;">var</span> outputBMP:Bitmap = <span style="color: #000000; font-weight: bold;">new</span> Bitmap<span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> BitmapData <span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #0066CC;">width</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + <span style="color: #cc66cc;">10</span>, sourceBMP.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">*</span><span style="color: #cc66cc;">2</span> + <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>, <span style="color: #ff0000;">&quot;auto&quot;</span>, <span style="color: #000000; font-weight: bold;">true</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> sourceRect:Rectangle = <span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>,sourceBMP.<span style="color: #0066CC;">width</span>, sourceBMP.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> blueTransform:ColorTransform = <span style="color: #000000; font-weight: bold;">new</span> ColorTransform<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> yellowTransform:ColorTransform = <span style="color: #000000; font-weight: bold;">new</span> ColorTransform<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> greenTransform:ColorTransform = <span style="color: #000000; font-weight: bold;">new</span> ColorTransform<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> redTransform:ColorTransform = <span style="color: #000000; font-weight: bold;">new</span> ColorTransform<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">1</span>,<span style="color: #cc66cc;">1</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #006600;">bitmapData</span>, sourceRect, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #006600;">bitmapData</span>, sourceRect, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>, sourceBMP.<span style="color: #0066CC;">height</span> + <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #006600;">bitmapData</span>, sourceRect, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #0066CC;">width</span> + <span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">copyPixels</span><span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #006600;">bitmapData</span>, sourceRect, <span style="color: #000000; font-weight: bold;">new</span> Point<span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #0066CC;">width</span> + <span style="color: #cc66cc;">10</span>, sourceBMP.<span style="color: #0066CC;">height</span> + <span style="color: #cc66cc;">10</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">colorTransform</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span>, sourceBMP.<span style="color: #0066CC;">width</span>, sourceBMP.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>, blueTransform<span style="color: #66cc66;">&#41;</span>;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">colorTransform</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #0066CC;">width</span>+<span style="color: #cc66cc;">10</span>, <span style="color: #cc66cc;">0</span>, sourceBMP.<span style="color: #0066CC;">width</span>, sourceBMP.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>, yellowTransform<span style="color: #66cc66;">&#41;</span>;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">colorTransform</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,sourceBMP.<span style="color: #0066CC;">height</span> + <span style="color: #cc66cc;">10</span>, sourceBMP.<span style="color: #0066CC;">width</span>, sourceBMP.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>, redTransform<span style="color: #66cc66;">&#41;</span>;
	outputBMP.<span style="color: #006600;">bitmapData</span>.<span style="color: #006600;">colorTransform</span><span style="color: #66cc66;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> Rectangle<span style="color: #66cc66;">&#40;</span>sourceBMP.<span style="color: #0066CC;">width</span>+<span style="color: #cc66cc;">10</span>,sourceBMP.<span style="color: #0066CC;">height</span>+<span style="color: #cc66cc;">10</span>, sourceBMP.<span style="color: #0066CC;">width</span>, sourceBMP.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span>, greenTransform<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> ratio:<span style="color: #0066CC;">Number</span> = outputBMP.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> outputBMP.<span style="color: #0066CC;">height</span>;
	<span style="color: #000000; font-weight: bold;">var</span> sourceRatio:<span style="color: #0066CC;">Number</span> = sourceBMP.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> sourceBMP.<span style="color: #0066CC;">height</span>;
	sourceBMP.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">200</span>;
	sourceBMP.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">200</span><span style="color: #66cc66;">/</span>ratio;
&nbsp;
<span style="color: #b1b100;">if</span> <span style="color: #66cc66;">&#40;</span>outputPanel.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">&gt;</span> outputPanel.<span style="color: #0066CC;">height</span><span style="color: #66cc66;">&#41;</span> <span style="color: #66cc66;">&#123;</span>
	outputBMP.<span style="color: #0066CC;">height</span> = outputPanel.<span style="color: #0066CC;">height</span> - <span style="color: #cc66cc;">100</span>;
	outputBMP.<span style="color: #0066CC;">width</span> = outputBMP.<span style="color: #0066CC;">height</span> <span style="color: #66cc66;">*</span> ratio;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #b1b100;">else</span> <span style="color: #66cc66;">&#123;</span>
	outputBMP.<span style="color: #0066CC;">width</span> = outputPanel.<span style="color: #0066CC;">width</span> - <span style="color: #cc66cc;">50</span>;
	outputBMP.<span style="color: #0066CC;">height</span> = outputBMP.<span style="color: #0066CC;">width</span> <span style="color: #66cc66;">/</span> ratio;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">var</span> outputContainer:UIComponent = <span style="color: #000000; font-weight: bold;">new</span> UIComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> sourceContainer:UIComponent = <span style="color: #000000; font-weight: bold;">new</span> UIComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	<span style="color: #000000; font-weight: bold;">var</span> arrowContainer:UIComponent = <span style="color: #000000; font-weight: bold;">new</span> UIComponent<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	sourceContainer.<span style="color: #0066CC;">width</span> = sourceBMP.<span style="color: #0066CC;">width</span>;
	sourceContainer.<span style="color: #0066CC;">height</span> = sourceBMP.<span style="color: #0066CC;">height</span>;
&nbsp;
	outputContainer.<span style="color: #0066CC;">width</span> = outputBMP.<span style="color: #0066CC;">width</span>;
	outputContainer.<span style="color: #0066CC;">height</span> = outputBMP.<span style="color: #0066CC;">height</span>;
&nbsp;
	arrowContainer.<span style="color: #0066CC;">width</span> = <span style="color: #cc66cc;">10</span>;
	arrowContainer.<span style="color: #0066CC;">height</span> = <span style="color: #cc66cc;">40</span>;
&nbsp;
	sourceContainer.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>sourceBMP<span style="color: #66cc66;">&#41;</span>;
	arrowContainer.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>drawArrow<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>;
	outputContainer.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>outputBMP<span style="color: #66cc66;">&#41;</span>;
&nbsp;
	outputPanel.<span style="color: #006600;">removeAllChildren</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
&nbsp;
	outputPanel.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>sourceContainer<span style="color: #66cc66;">&#41;</span>;
	outputPanel.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>arrowContainer<span style="color: #66cc66;">&#41;</span>;
	outputPanel.<span style="color: #006600;">addChild</span><span style="color: #66cc66;">&#40;</span>outputContainer<span style="color: #66cc66;">&#41;</span>;
<span style="color: #66cc66;">&#125;</span>
&nbsp;
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">function</span> drawArrow <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span> : Sprite <span style="color: #66cc66;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">var</span> targetSprite:Sprite = <span style="color: #000000; font-weight: bold;">new</span> Sprite<span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;
	targetSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">beginFill</span><span style="color: #66cc66;">&#40;</span>0x000000<span style="color: #66cc66;">&#41;</span>;
	targetSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">10</span>,<span style="color: #cc66cc;">20</span><span style="color: #66cc66;">&#41;</span>;
	targetSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">40</span><span style="color: #66cc66;">&#41;</span>;
	targetSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">lineTo</span><span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">0</span>,<span style="color: #cc66cc;">0</span><span style="color: #66cc66;">&#41;</span>;
	targetSprite.<span style="color: #006600;">graphics</span>.<span style="color: #0066CC;">endFill</span><span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>;	
<span style="color: #b1b100;">return</span> targetSprite;
<span style="color: #66cc66;">&#125;</span>
<span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&#93;</span><span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Script<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:<span style="color: #0066CC;">Button</span> id=<span style="color: #ff0000;">&quot;browseButton&quot;</span> label=<span style="color: #ff0000;">&quot;Browse for an image&quot;</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">&quot;10&quot;</span> top=<span style="color: #ff0000;">&quot;10&quot;</span> click=<span style="color: #ff0000;">&quot;handleBrowseClick();&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:TextInput id=<span style="color: #ff0000;">&quot;fileName&quot;</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">&quot;166&quot;</span> top=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Label <span style="color: #0066CC;">text</span>=<span style="color: #ff0000;">&quot;Warholizer&quot;</span> fontWeight=<span style="color: #ff0000;">&quot;bold&quot;</span> fontSize=<span style="color: #ff0000;">&quot;17&quot;</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">&quot;7&quot;</span> top=<span style="color: #ff0000;">&quot;6&quot;</span><span style="color: #66cc66;">/&gt;</span>
<span style="color: #66cc66;">&lt;</span>mx:Panel layout=<span style="color: #ff0000;">&quot;horizontal&quot;</span> bottom=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">right</span>=<span style="color: #ff0000;">&quot;10&quot;</span> <span style="color: #0066CC;">left</span>=<span style="color: #ff0000;">&quot;10&quot;</span> top=<span style="color: #ff0000;">&quot;41&quot;</span> id=<span style="color: #ff0000;">&quot;outputPanel&quot;</span> clipContent=<span style="color: #ff0000;">&quot;true&quot;</span> title=<span style="color: #ff0000;">&quot;Output&quot;</span> horizontalAlign=<span style="color: #ff0000;">&quot;center&quot;</span> verticalAlign=<span style="color: #ff0000;">&quot;middle&quot;</span><span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Panel<span style="color: #66cc66;">&gt;</span>
<span style="color: #66cc66;">&lt;/</span>mx:Application<span style="color: #66cc66;">&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2008/12/22/flash-10-experiments-the-warholizer-loading-and-processing-local-images/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ASTRA Holiday Edition</title>
		<link>http://www.yswfblog.com/blog/2008/12/11/astra-holiday-edition/</link>
		<comments>http://www.yswfblog.com/blog/2008/12/11/astra-holiday-edition/#comments</comments>
		<pubDate>Thu, 11 Dec 2008 18:24:14 +0000</pubDate>
		<dc:creator>Alaric Cole</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/2008/12/11/astra-holiday-edition/</guid>
		<description><![CDATA[It&#8217;s that time of year again. A time when spirits are high, and an unmistakable sense of well-being enters your heart. A time when a peaceful stillness fills the air, and carols can be heard, sung merrily in the distance.
That&#8217;s right, it&#8217;s time for an ASTRA bug release! Oh, for joy!
The Flash Platform team worked [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s that time of year again. A time when spirits are high, and an unmistakable sense of well-being enters your heart. A time when a peaceful stillness fills the air, and carols can be heard, sung merrily in the distance.</p>
<p>That&#8217;s right, it&#8217;s time for an <em>ASTRA bug release</em>! Oh, for joy!</p>
<p>The Flash Platform team worked overtime on this one. Heck, we could even be seen on Thanksgiving, hacking code in between bites of Grandma&#8217;s pumpkin pie. We did everything we could to fix things that needed fixing, and add things that needed adding. And so, without further ado, we present to you, <a href="http://developer.yahoo.com/flash/">ASTRA 1.3.1</a>.</p>
<h4>Fixes and feature enhancements:</h4>
<p>AlertManager<br />
o   Added support for styling.</p>
<p>AudioPlayback:<br />
o   Bug fix: scrubber would not work properly while large file downloads.</p>
<p>AutoComplete:<br />
o   Bug fix: Fixed bug with ASTRA layout containers.<br />
o   Made itemToLabel function public.</p>
<p>Menu:<br />
o   Added support for styling.<br />
o   Added accessibility placeholders.<br />
o   Bug fix: Fixed bug with MenuEvent not sending out appropriate menu property.</p>
<p>MenuBar:<br />
o   Added support for styling.<br />
o   Bug fix: Fixed bug in which LivePreview was not showing properly in CS4 when component was dragged to stage.</p>
<p>Tree:<br />
o   Bug fix: Fixed index overrun bug.<br />
o   Bug fix: Fixed shifting selected item when opening and closing.</p>
<p>So grab a glass of eggnog and sit by the fire, and pick up the <a href="http://developer.yahoo.com/flash/">new ASTRA</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2008/12/11/astra-holiday-edition/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Creating Accessible Components in Flash and Flex</title>
		<link>http://www.yswfblog.com/blog/2008/12/05/creating-accessible-components-in-flash-and-flex/</link>
		<comments>http://www.yswfblog.com/blog/2008/12/05/creating-accessible-components-in-flash-and-flex/#comments</comments>
		<pubDate>Fri, 05 Dec 2008 13:00:57 +0000</pubDate>
		<dc:creator>Alaric Cole</dc:creator>
				<category><![CDATA[Articles]]></category>
		<category><![CDATA[Flash]]></category>
		<category><![CDATA[Flex]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/2008/12/05/creating-accessible-components-in-flash-and-flex/</guid>
		<description><![CDATA[It&#8217;s been in the works for a while, but I finally had the chance to focus on making ASTRA components more accessible. Accessibility is not something many developers look at, but it&#8217;s slowly gaining ground. For many developers, even figuring out how to enable the built-in accessibility of Flash components is a job. But when [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been in the works for a while, but I finally had the chance to focus on making ASTRA components more accessible. Accessibility is not something many developers look at, but it&#8217;s slowly gaining ground. For many developers, even figuring out how to enable the built-in accessibility of Flash components is a job. But when you create custom components, implementing accessibility is another job entirely. Accessibility doesn&#8217;t come for free.</p>
<table border="0" cellspacing="5" cellpadding="10" width="200" align="right">
<tbody>
<tr>
<td bgcolor="#75a3d1"><span>This set of articles will be geared towards component developers who want to ensure compatibility with screen readers. However, any developer will find this information useful, especially those want to learn how accessibility works in Flash.</span></td>
</tr>
</tbody>
</table>
<p>To begin my assessment of ASTRA components, I first had to learn to use a screen reader. I installed a trial of <a href="http://www.freedomscientific.com/fs_products/software_jaws.asp">JAWS for Windows</a>, which is the de facto screen reader technology, especially in regards to Flash. It&#8217;s important to note that although I develop on a Mac, I have to use Windows for accessibility testing. This is because Flash accessibility is based on <a href="http://msdn.microsoft.com/en-us/library/ms697707.aspx">Microsoft&#8217;s Active Accessibility</a> standards, and only work on Windows machines. It can be argued that real accessibility is quite limited on the Mac, so this is more of an OS X limitation than a limitation of Flash. I also installed the <a href="http://www.adobe.com/macromedia/accessibility/features/flex/readme.html">Flex scripts</a> add-ons, which are touted to provide more fine-grained info for the screen reader when using accessible Flex components.</p>
<p>Using  a screen reader, I quickly discovered, is a more involved process than it might seem. Your natural tendencies and habits have to be thrown out the window. For example, opening a browser window with an embedded swf, my first inclination was to use the mouse to navigate to a text input control and start typing. That didn&#8217;t work as planned. For one, a typical user of a screen reader is not going to be grabbing the mouse first thing, but using keyboard navigation to interact with an application, so I&#8217;d already cheated. Along with this, because of the way JAWS works, navigating to an input field won&#8217;t necessarily allow you to begin editing text&#8211;you must enter into &#8220;forms mode&#8221; in order to even start typing.</p>
<p>Once I got the basics of using JAWS down, I started to test our components. My original assumption was that the components would &#8220;mostly work&#8221; because many of them are based on lower-level components which have accessibility implementations built.</p>
<p>I was &#8220;mostly wrong.&#8221; A component is not the sum of its parts, in regards to a screen reader. For a component to be successfully understood by the user, it needs its own accessibility implementation built from scratch.</p>
<p>In the <a href="http://www.yswfblog.com/blog/2009/01/12/creating-accessible-components-in-flash-and-flex-part-2/">next article</a> I&#8217;ll discuss what steps I took to create those implementations.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2008/12/05/creating-accessible-components-in-flash-and-flex/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Where in the World Is Yahoo! Flash Platform? (Answer: Adobe Max 2008)</title>
		<link>http://www.yswfblog.com/blog/2008/11/14/where-in-the-world-is-yahoo-flash-platform-answer-adobe-max-2008/</link>
		<comments>http://www.yswfblog.com/blog/2008/11/14/where-in-the-world-is-yahoo-flash-platform-answer-adobe-max-2008/#comments</comments>
		<pubDate>Fri, 14 Nov 2008 19:13:57 +0000</pubDate>
		<dc:creator>Allen Rabinovich</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/2008/11/14/where-in-the-world-is-yahoo-flash-platform-answer-adobe-max-2008/</guid>
		<description><![CDATA[Well, we sneak around the world, from Kiev to Carolina, but next week, the big Adobe Max Developer Conference is coming to San Francisco, and we wanted to let you know that that&#8217;s where we&#8217;ll be! Yahoo! is a gold sponsor of the conference, and we&#8217;ll have a booth where someone will always be on [...]]]></description>
			<content:encoded><![CDATA[<p>Well, we <a href="http://lyricwiki.org/Rockapella:Where_In_The_World_Is_Carmen_San_Diego%3F" target="_blank">sneak around the world</a>, from Kiev to Carolina, but next week, the big <a href="http://www.adobemax08.com/na/experience/#?s=0&amp;p=0" target="_blank">Adobe Max Developer Conference</a> is coming to San Francisco, and we wanted to let you know that that&#8217;s where we&#8217;ll be! Yahoo! is a gold sponsor of the conference, and we&#8217;ll have a booth where someone will always be on hand to valiantly answer your questions and distribute schwag. We will also have two sessions in the &#8220;Develop&#8221; track. Here are the session blurbs:</p>
<blockquote><p> <strong>Hybrid Applications: Where JavaScript and Flash Play Together</strong><br />
<em>Monday, November 17th, 5—6 PM, Moscone West 2012<br />
</em></p>
<p>Although JavaScript is frequently the first choice for building RIAs, it is limited by browser capabilities. For that reason, JavaScript is missing some of the most essential features: vector drawing, improved file uploading, local storage, video playback, and so on. In this session, we&#8217;ll present a solution to this problem in the form of hybrid components. Hybrid components are applications built with Flash whose functionality is exposed to JavaScript and allows them to be used just like regular JavaScript components. We&#8217;ll go over the architecture of hybrids and showcase those developed for Yahoo!&#8217;s popular open source YUI library.</p></blockquote>
<blockquote><p> <strong>Yahoo! ASTRA and YUI: Open Source Front-End Components for Every Occasion</strong><br />
Wednesday, November 19th, 2—3 PM, Moscone West 2012</p>
<p>Yahoo! front-end platform teams have a unique approach to developing software: Although they work for a commercial enterprise, everything they do is free and open source. In this session, Yahoo! representatives will cover the work they&#8217;ve been doing for three years, from the award-winning YUI Library (preview YUI 3.0) to the Flash and Flex components in the ASTRA Library to the ActionScript 3 Maps API. The components they build solve real problems and can be leveraged by other companies. We&#8217;ll look at the source of a few components to see how they were built and provide insight into component development.</p></blockquote>
<p>We&#8217;ll record screencasts of both of these sessions and post them on this blog, so noone will miss out.</p>
<p>And if you are registered for Adobe Max, then see you soon!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2008/11/14/where-in-the-world-is-yahoo-flash-platform-answer-adobe-max-2008/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>3D with Flash 10 (part 2)</title>
		<link>http://www.yswfblog.com/blog/2008/11/12/3d-with-flash-10-part-2/</link>
		<comments>http://www.yswfblog.com/blog/2008/11/12/3d-with-flash-10-part-2/#comments</comments>
		<pubDate>Wed, 12 Nov 2008 15:41:37 +0000</pubDate>
		<dc:creator>Michael Hoch</dc:creator>
				<category><![CDATA[Flash]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.yswfblog.com/blog/2008/11/12/3d-with-flash-10-part-2/</guid>
		<description><![CDATA[
Overview
When I came across Flash 10 two things caught my attention: 3D Effects and PixelBender Filters. This post will explore the former: Flash 10 adds a set of utility functions to do 3D Effects that were previously difficult or costly. I wanted to explore the possibility to export 3D Models from 3D animation packages to [...]]]></description>
			<content:encoded><![CDATA[<p><script src="http://us.js2.yimg.com/us.js.yimg.com/lib/flash/swfobject/1.0/swfobject.js" type="text/javascript"></script></p>
<h3><strong>Overview</strong></h3>
<p>When I came across Flash 10 two things caught my attention: 3D Effects and PixelBender Filters. This post will explore the former: Flash 10 adds a set of utility functions to do 3D Effects that were previously difficult or costly. I wanted to explore the possibility to export 3D Models from 3D animation packages to Flash 10 directly. Now, there are existing 3D engines like Papervision, Away3D, and Sandy that provide the functionality for rendering 3D objects and scenes. There are also functions for reading in data from 3D formats like 3DMax. However, the purpose of this blog post is  an exploration of the new functionality offered in Flash 10 and describe a minimalist approach to how to render a 3D object using some of these new functions.</p>
<p style="text-align: center">&nbsp;</p>
<p id="swfdiv1" style="text-align: center">Note: The proper version of <a href="http://www.adobe.com/go/getflashplayer">Flash Player</a> is not installed or JavaScript is not enabled. Unable to display SWF content.</p>
<p><script type="text/javascript"> var swfobj = new SWFObject( "http://www.yswfblog.com/blog/wp-content/uploads/2008/11/3d_cube.swf", "3D Ring", "200", "200", "10.0.0" ); swfobj.write( "swfdiv1" ); </script></p>
<h3><strong>New functions</strong></h3>
<h4>Vector</h4>
<p>Flash 10 introduces the notion of typed arrays &#8211; arrays that can only contain  values of a certain type &#8211; which improves performance and makes your code also more transparent. We can use it to store the vertex data of our 3D object (as well as a similar vector for our indices that define the face set). You can simply create an empty Vector and then push the vertices:</p>
<blockquote><p>       var vertices3D:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;();<br />
vertices3D.push(x, y, z);</p></blockquote>
<p>You can also pre-specify the size:</p>
<blockquote><p>      var vertices3D:Vector.&lt;Number&gt; = new Vector.&lt;Number&gt;(30);<br />
vertices3D[0] = x;<br />
vertices3D[1] = y;<br />
vertices3D[2] = z;</p></blockquote>
<p>or just pass in an array:</p>
<blockquote><p>      var vertices3D:Vector.&lt;Number&gt; = Vector.&lt;Number&gt;([ 0.3, 0.7, 0.1 ]);</p></blockquote>
<p>Watch out for not using &#8220;new&#8221; when initializing a Vector with an array.</p>
<h4>Perspective Projection</h4>
<p>Once we have our vertex data we can set up our rendering pipeline with a perspective projection. Flash 10 offers the class <em>PerspectiveProjection </em>that allows us to set the projection center and the field of view through properties.</p>
<blockquote><p>     var pp:PerspectiveProjection = new PerspectiveProjection();<br />
pp.projectionCenter = new Point(0, 0);<br />
pp.fieldOfView = 45;</p></blockquote>
<h4>Project Vectors</h4>
<p>Next, we use the projection matrix and one of the new 3D utility functions to project our vertex data into 2D space. Below we use the typed array vertices2D to hold the resulting data (note that this function also calculates the t-value of the uvtData which can be used for texture mapping).</p>
<blockquote><p>   m:Matrix3D = pp.toMatrix();<br />
Utils3D.projectVectors(m, myMesh.vertices3D, myMesh.vertices2D, myMesh.uvtData);</p></blockquote>
<h4>Draw Triangles</h4>
<p>Finally, we can draw our resulting 2D mesh on the screen using the new <em>drawTriangles()</em> function. This function takes our calculated 2D vertex data array, the original index data, and specifies which sides should be rendered through the culling parameter. A parameter of <em>TriangleCulling.POSITIVE</em> results in only positively wound triangles to be drawn.</p>
<blockquote><p>     container.graphics.clear();<br />
container.graphics.beginFill(0xbbbbbb, 1);<br />
container.graphics.lineStyle(0, 0&#215;666666, 1);<br />
container.graphics.drawTriangles(myMesh.vertices2D, myMesh.indices, null, TriangleCulling.POSITIVE);</p></blockquote>
<h4>Adding interactivity</h4>
<p>In order to add interactivity &#8211; say rotate our object via mouse movements &#8211; we can introduce one additional step before we call <em>projectVectors()</em>: We can use the new Matrix3D functions to add translation and rotation parameters.</p>
<blockquote><p>m2:Matrix3D = new Matrix3D();<br />
m2.identity();<br />
m2.prependTranslation(1, 0, 5);<br />
m2.prependRotation(rotY, Vector3D.Y_AXIS);<br />
m2.prependRotation(rotX, Vector3D.X_AXIS);<br />
m2.transformVectors(myMesh.vertices3D, myMesh.vertices3D2);<br />
Utils3D.projectVectors(m, myMesh.vertices3D2, myMesh.vertices2D, myMesh.uvtData);</p></blockquote>
<h4>Export from 3D Package</h4>
<p>Now that we can render 3D objects we like to use polygonal models from a 3D package. There are a set of ASCII formats that can easily be converted to ActionScript arrays (e.g. VRML or obj). In case of the open source animation system Blender there are also scripts that directly export to Actionscript compatible with Sandy, Papervision and Away3D. It is easy to create a similar script to export to a simple AS3 mesh class that holds the data for our vertices3D, our indices of the face set, as well as provides the arrays for vertices2D and uvtData.</p>
<p>See some results of simple 3D objects:</p>
<p style="text-align: center">&nbsp;</p>
<p id="swfdiv3" style="text-align: center">Note: The proper version of <a href="http://www.adobe.com/go/getflashplayer">Flash Player</a> is not installed or JavaScript is not enabled. Unable to display SWF content.</p>
<p><script type="text/javascript"> var swfobj = new SWFObject( "http://www.yswfblog.com/blog/wp-content/uploads/2008/11/3d_ring.swf", "3D Ring", "200", "200", "10.0.0" ); swfobj.write( "swfdiv3" ); </script></p>
<p id="swfdiv4" style="text-align: center">Note: The proper version of <a href="http://www.adobe.com/go/getflashplayer">Flash Player</a> is not installed or JavaScript is not enabled. Unable to display SWF content.</p>
<p><script type="text/javascript"> var swfobj = new SWFObject( "http://www.yswfblog.com/blog/wp-content/uploads/2008/11/3d_torus.swf", "3D Ring", "200", "200", "10.0.0" ); swfobj.write( "swfdiv4" ); </script></p>
<p>Attached is the <a href="http://www.yswfblog.com/blog/wp-content/uploads/2008/11/source.zip">source for the 3d Cube</a>.</p>
<p>&#8230; to be continued</p>
]]></content:encoded>
			<wfw:commentRss>http://www.yswfblog.com/blog/2008/11/12/3d-with-flash-10-part-2/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
