<?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>FlexWiz Blog &#187; Flex 4</title>
	<atom:link href="http://blog.flexwiz.net/category/flex/flex4/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexwiz.net</link>
	<description>On Game Development and the Flash platform</description>
	<lastBuildDate>Sat, 17 Dec 2011 22:46:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Flex 4.5 – A ‘Hero’s Welcome</title>
		<link>http://blog.flexwiz.net/flex-4-5-a-hero-welcome/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=flex-4-5-a-hero-welcome</link>
		<comments>http://blog.flexwiz.net/flex-4-5-a-hero-welcome/#comments</comments>
		<pubDate>Wed, 26 Jan 2011 23:20:43 +0000</pubDate>
		<dc:creator>theWiz</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Hero]]></category>
		<category><![CDATA[Skinning]]></category>
		<category><![CDATA[Spark]]></category>

		<guid isPermaLink="false">http://flexwiz.amosl.com/?p=433</guid>
		<description><![CDATA[It&#8217;s been a while since Flex 4.5 public beta was released. I spent some time with the the new SDK and following blogs, getting the feel of it.  The 4.5 &#8220;Hero&#8221; SDK is expected to release later this year, along with a new version of flash player (10.2) . In previous posts (Spark pains) I expressed my disappointment [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright size-full wp-image-449" style="margin: 4px;" title="hero" src="http://blog.flexwiz.net/wp-content/uploads/2011/01/hero.png" alt="" width="216" height="176" />It&#8217;s been a while since Flex 4.5 public beta was released. I spent some time with the the new SDK and following blogs, getting the feel of it.  The 4.5 &#8220;Hero&#8221; SDK is expected to release later this year, along with a new version of flash player (10.2) .</p>
<p>In previous posts (<a href="http://blog.flexwiz.net/flex/spark-pains-is-it-worth-it/" target="_blank">Spark pains</a>) I expressed my disappointment with Spark&#8217;s lack of functionality versus the Flex 3 mx components it came to replace. <a href="http://jessewarden.com/2010/09/adobe-please-bring-flash-builder-up-to-par.html" target="_blank">Like others</a>, I shared the notion that Spark is half baked, and Adobe should have included a more complete solution in version 4.0 or 4.1, at least for the included components like button or image. Let&#8217;s see what is in for us in the upcoming Flex 4.5 (&#8220;Hero&#8221;).</p>
<p><span id="more-433"></span></p>
<h3>Spark Button: The return of the Icon</h3>
<p>Good news &#8211; the icon style is back to Spark button!  After spending a lot of time writing custom skins and specialized classes I was glad to see that the spark button now supports icon out of the box, just like the good old mx button. Too bad it came  late for my recent projects, all using spark buttons, cluttered with custom skins only to achieve the trivial task of putting an icon in a button.</p>
<p>By any reasonable standard, we should have had these  in Flex 4.0 release last year.</p>
<p>I can only reiterate the comment in a post in the <a href="http://blog.flexexamples.com/" target="_blank">Flex Examples</a> blog: all that to get what we’ve had for years in Flex 3.  I really am glad these basic features are back, but was it really necessary to wait over a year to have it back (and require Flash 10.2 player)?</p>
<p>Really, Adobe &#8211; is that too much to expect?</p>
<h3>Spark Bitmap Image</h3>
<p>Another source of frustration for me was the spark BitmapImage. Made to replace mx image, it gave similar functionality&#8230; well, almost. No support for runtime loading and display of timeline swfs forced me and my team to fall-back to mx image for no other alternative.</p>
<p>Even worse, the overblown security model made image caching almost impossible to implement. Try constantly loading images from services like flikr and facebook and see what I mean. Policy files, trusted or untrusted domains, nothing seems to work properly. To actually make it possible to access bitmapData, everyone uses a PHP script to bypass the flash player security model &#8211; not very elegant.</p>
<p>A Hero to the rescue, Flex 4.5 brings the new and improved  BitmapImage with all of mx image features and built it image caching &#8211; Hallelujah!  they even threw in smart scaling and letterbox mode.  It&#8217;s too soon to comment on how effective it is since it is still in beta, but kudos to Adobe for doing the right thing.</p>
<p>What more can I say? Better late than never.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flexwiz.net/flex-4-5-a-hero-welcome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Spark List with Zoom Effect</title>
		<link>http://blog.flexwiz.net/spark-list-with-zoom-effect/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=spark-list-with-zoom-effect</link>
		<comments>http://blog.flexwiz.net/spark-list-with-zoom-effect/#comments</comments>
		<pubDate>Mon, 11 Oct 2010 15:30:58 +0000</pubDate>
		<dc:creator>theWiz</dc:creator>
				<category><![CDATA[Flex]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[Skinning]]></category>
		<category><![CDATA[Spark]]></category>

		<guid isPermaLink="false">http://flexwiz.amosl.com/?p=379</guid>
		<description><![CDATA[For a recent project  I needed to create a trivial image list with zoom effect for a spark based application. Image lists are commonly used for image galleries or menus, and Flex offers some UI components to quickly create and configure these generic lists, so I did not expect any difficulties. I was wrong. Even [...]]]></description>
			<content:encoded><![CDATA[<p>For a recent project  I needed to create a trivial image list with zoom effect for a spark based application. Image lists are commonly used for image galleries or menus, and Flex offers some UI components to quickly create and configure these generic lists, so I did not expect any difficulties.<br />
I was wrong. Even though creating image lists became an almost trivial task, there are a few pitfalls and none of the samples posted by Adobe were clear enough to address them. After spending some time with <a href="http://www.adobe.com/devnet-archive/flex/tourdeflex/web/#" target="_blank">tour-de-flex</a> samples I managed to come up with a different working solution.</p>
<p>This is what I needed:<br />
<img class="alignnone size-full wp-image-396" title="imgZoom" src="http://blog.flexwiz.net/wp-content/uploads/2010/10/imgZoom.png" alt="" width="550" height="167" /><br />
<span id="more-379"></span></p>
<h2>Basic Image List</h2>
<p>First of all lets consider the options. A list can be created by either a DataGroup or a spark List. Both components can display a list based on data provider and item renderer, but there are a few differences, summarized here:</p>
<ol>
<li>List is skinnable, DataGroup is not.</li>
<li>DataGroup is much lighter</li>
<li>List provides  additional  functionality, namely selection and drag-drop</li>
</ol>
<p>Since I needed the select functionality I decided to go with the List.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:List</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;lst1&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">dataProvider</span>=<span style="color: #ff0000;">&quot;{sampleData}&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">itemRenderer</span>=<span style="color: #ff0000;">&quot;cc.ImageRenderer&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">rollOverColor</span>=<span style="color: #ff0000;">&quot;#cccccc&quot;</span> <span style="color: #000066;">selectionColor</span>=<span style="color: #ff0000;">&quot;#eeee00&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">width</span>=<span style="color: #ff0000;">&quot;100%&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:HorizontalLayout</span> <span style="color: #000066;">gap</span>=<span style="color: #ff0000;">&quot;4&quot;</span><span style="color: #000000; font-weight: bold;">/&gt;</span></span>
       <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:layout<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
 <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:List<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>The Item Renderer</h2>
<p>Start with a basic renderer from a template: &#8216;New-&gt;MXML Item Renderer&#8217;. Add an image control as the main display object, and optionally some background. If you try to run you&#8217;ll get a list with static images.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:states<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;normal&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;hovered&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:State</span> <span style="color: #000066;">name</span>=<span style="color: #ff0000;">&quot;selected&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:states<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Rect</span> <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;0&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:fill<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:SolidColor</span></span>
<span style="color: #009900;">            <span style="color: #000066;">color.normal</span>=<span style="color: #ff0000;">&quot;0x808080&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">color.hovered</span>=<span style="color: #ff0000;">&quot;{getStyle('rollOverColor')}&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000066;">color.selected</span>=<span style="color: #ff0000;">&quot;{getStyle('selectionColor')}&quot;</span></span>
<span style="color: #009900;">            <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:fill<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Rect<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;mx:Image</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;img&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">verticalAlign</span>=<span style="color: #ff0000;">&quot;middle&quot;</span> <span style="color: #000066;">horizontalAlign</span>=<span style="color: #ff0000;">&quot;center&quot;</span></span>
<span style="color: #009900;">          <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;4&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span></pre></div></div>

<p>Note that I took advantage of the styles for selection and rollover colors.<br />
Now we add the effect, using the postLayoutTransformOffsets property of the item renderer.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--       The Zoom effect      --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:postLayoutTransformOffsets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:TransformOffsets</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;tOffsets&quot;</span></span>
<span style="color: #009900;">                        <span style="color: #000066;">scaleX</span>=<span style="color: #ff0000;">&quot;1&quot;</span> <span style="color: #000066;">scaleY</span>=<span style="color: #ff0000;">&quot;1&quot;</span></span>
<span style="color: #009900;">                        <span style="color: #000066;">scaleX.hovered</span>=<span style="color: #ff0000;">&quot;1.5&quot;</span> <span style="color: #000066;">scaleY.hovered</span>=<span style="color: #ff0000;">&quot;1.5&quot;</span></span>
<span style="color: #009900;">                        <span style="color: #000066;">scaleX.selected</span>=<span style="color: #ff0000;">&quot;1.1&quot;</span> <span style="color: #000066;">scaleY.selected</span>=<span style="color: #ff0000;">&quot;1.1&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:postLayoutTransformOffsets<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #808080; font-style: italic;">&lt;!--       Transitions          --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:transitions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Transition</span> <span style="color: #000066;">toState</span>=<span style="color: #ff0000;">&quot;hovered&quot;</span> <span style="color: #000066;">autoReverse</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Animate</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;{tOffsets}&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:SimpleMotionPath</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;scaleX&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:SimpleMotionPath</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;scaleY&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Animate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Transition<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Transition</span> <span style="color: #000066;">fromState</span>=<span style="color: #ff0000;">&quot;hovered&quot;</span> <span style="color: #000066;">autoReverse</span>=<span style="color: #ff0000;">&quot;true&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Animate</span> <span style="color: #000066;">target</span>=<span style="color: #ff0000;">&quot;{tOffsets}&quot;</span> <span style="color: #000066;">duration</span>=<span style="color: #ff0000;">&quot;200&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:SimpleMotionPath</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;scaleX&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
            <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:SimpleMotionPath</span> <span style="color: #000066;">property</span>=<span style="color: #ff0000;">&quot;scaleY&quot;</span> <span style="color: #000000; font-weight: bold;">/&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Animate<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Transition<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:transitions<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>To make the scale work from the center, simply set transformX and transformY to half the size of the renderer. Run the code and see the nice zoom effect on rollover. Works nice overall, but there is one problem &#8211; since the items are scaled during the effect, the area for the list is based on the normal scale, clipping the oversized item on the edges of the list. Simply put, we need some more space between the list and its container &#8211; which brings us to skinning.</p>
<h2>Skinning the list</h2>
<p>The default skin for spark list is basically a DataGroup enclosed within a scroll component. Simply adding margins between the list and the scroller will not do &#8211; the images would still get clipped. We need to wrap the list in a group, so that clipping can be controlled. Replacing the scroller block with the following code will do the trick.</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">&lt;!--- The Scroller component to add scroll bars to the list. --&gt;</span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Scroller</span> <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;scroller&quot;</span> <span style="color: #000000; font-weight: bold;">&gt;</span></span>
&nbsp;
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:Group</span> <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;0&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;10&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;s:DataGroup</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;dataGroup&quot;</span></span>
<span style="color: #009900;">                     <span style="color: #000066;">left</span>=<span style="color: #ff0000;">&quot;22&quot;</span> <span style="color: #000066;">top</span>=<span style="color: #ff0000;">&quot;26&quot;</span> <span style="color: #000066;">right</span>=<span style="color: #ff0000;">&quot;22&quot;</span> <span style="color: #000066;">bottom</span>=<span style="color: #ff0000;">&quot;26&quot;</span></span>
<span style="color: #009900;">                     <span style="color: #000066;">itemRenderer</span>=<span style="color: #ff0000;">&quot;spark.skins.spark.DefaultItemRenderer&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:DataGroup<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Group<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
&nbsp;
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/s:Scroller<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<h2>Final Result</h2>
<p> <a href="http://blog.flexwiz.net/sources/listdemo/bin/ListDemo.swf" target="_blank"><img src="http://blog.flexwiz.net/wp-content/uploads/2010/10/demo_button.png" alt="" title="View Demo" width="200" height="60" class="alignnone size-full wp-image-410" /></a>    <a href="http://blog.flexwiz.net/sources/listdemo/" target="_blank"><img src="http://blog.flexwiz.net/wp-content/uploads/2010/10/ViewSource.png" alt="" title="View Source" width="200" height="60" class="alignnone size-full wp-image-412" /></a></p>
<p>The demo app contains the three different lists to compare the effect of the skin and rederer.<br />
Looking at the final result, we got a slightly modified skin for the list and the item renderer. Most of the effort went on skinning &#8211; not bad, considering the list itself and the effect are used almost out of the box.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.flexwiz.net/spark-list-with-zoom-effect/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

