<?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>creacog &#187; Spark components</title>
	<atom:link href="http://blog.creacog.co.uk/category/adobe/flex/spark-components/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.creacog.co.uk</link>
	<description></description>
	<lastBuildDate>Thu, 19 Jan 2012 16:43:10 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Flex4.6 mobile  maxChars bug/problem and workaround</title>
		<link>http://blog.creacog.co.uk/2012/01/19/flex4-6-mobile-maxchars-bugproblem-and-workaround/</link>
		<comments>http://blog.creacog.co.uk/2012/01/19/flex4-6-mobile-maxchars-bugproblem-and-workaround/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 15:23:22 +0000</pubDate>
		<dc:creator>creacog</dc:creator>
				<category><![CDATA[Flex Components]]></category>
		<category><![CDATA[Spark components]]></category>
		<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.creacog.co.uk/?p=633</guid>
		<description><![CDATA[Bug-note to self, and workaround while waiting for the bug-base to migrate from Adobe to Apache. I&#8217;m using in a Flex 4.6 mobile project and found that setting the maxChars property to 512 caused exeption: Main Thread (Suspended: ArgumentError: Error #2006: The supplied index is out of bounds.) flash.text::StageText/set viewPort [no source] spark.components.supportClasses::StyleableStageText/updateViewPort spark.components.supportClasses::StyleableStageText/commitProperties mx.core::UIComponent/validateProperties [...]]]></description>
			<content:encoded><![CDATA[<p>Bug-note to self, and workaround while waiting for the bug-base to migrate from Adobe to Apache.</p>
<p>I&#8217;m using  in a Flex 4.6 mobile project and found that setting the maxChars property to 512 caused exeption:</p>
<pre>Main Thread (Suspended: ArgumentError: Error #2006: The supplied index is out of bounds.)
flash.text::StageText/set viewPort [no source]
spark.components.supportClasses::StyleableStageText/updateViewPort
spark.components.supportClasses::StyleableStageText/commitProperties
mx.core::UIComponent/validateProperties
mx.managers::LayoutManager/validateProperties
mx.managers::LayoutManager/doPhasedInstantiation
mx.managers::LayoutManager/doPhasedInstantiationCallback</pre>
<p>However setting maxChars to something much smaller (e.g. 10) was fine. From experimentation, seems that the biggest number to which maxChars could be set without causing the problem was 481. I have no idea what that number relates to. Anyway the database field my TextInput corresponds to is 512 chars max so that&#8217;s the number I need.</p>
<p>The workaround:</p>
<p>Setting maxWidth on the TextInput seems to solve the problem. But rather than insert a constant I want the TextInput to flex to the width of it&#8217;s container, so the following seems to avoid the problem:</p>
<p>&nbsp;</p>
<p><code></p>
<blockquote><p>&lt;s:TextInput<br />
id        ="textInputId"<br />
maxWidth  ="{skinableContainerId.width}"<br />
maxChars  ="512" /&gt;</p></blockquote>
<p></code></p>
<p>&nbsp;</p>
<p>The future of Flex :</p>
<ul>
<li> <a href="http://incubator.apache.org/flex/">Apache Flex</a></li>
<li> <a href="http://blogs.apache.org/flex/">Apache Flex Blog</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.creacog.co.uk/2012/01/19/flex4-6-mobile-maxchars-bugproblem-and-workaround/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Flex 4 Spark VideoDisplay (measure, overlay, skin)</title>
		<link>http://blog.creacog.co.uk/2010/04/28/flex-4-spark-videodisplay-measure-overlay-skin/</link>
		<comments>http://blog.creacog.co.uk/2010/04/28/flex-4-spark-videodisplay-measure-overlay-skin/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 15:19:55 +0000</pubDate>
		<dc:creator>creacog</dc:creator>
				<category><![CDATA[Adobe]]></category>
		<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Flex Components]]></category>
		<category><![CDATA[Spark components]]></category>

		<guid isPermaLink="false">http://blog.creacog.co.uk/?p=430</guid>
		<description><![CDATA[In a previous article I described some of the steps required in Flex 3 in order to keep an overlay position in sync with a VideoDisplay component. With the release of Flex 4, VideoDisplay is one of the components to be updated. Via VideoPlayer, it gets a Spark makeover. Internally its core, or &#8216;view&#8217;, has [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a title="overlaying VideoDisplay with constrained fluid layout" href="http://blog.creacog.co.uk/2009/09/21/overlaying-videodisplay-with-constrained-fluid-layout/">previous article</a> I described some of the steps required in Flex 3 in order to keep an overlay position in sync with a VideoDisplay component. With the release of Flex 4, <code>VideoDisplay</code> is one of the components to be updated. Via <code>VideoPlayer</code>, it gets a Spark makeover. Internally its core, or &#8216;view&#8217;, has been reimplemented using <a title="Open Source Media Framework" href="http://opensource.adobe.com/wiki/display/osmf/Open+Source+Media+Framework;jsessionid=CE1EDF88AF0033D9CB2C60674FB4BA6E" target="_blank">Open Source Media Framework</a>. For anyone wishing to keep an overlay in position over the view, however, the same key issue remains:</p>
<blockquote><p>None of the various width or height properties of the VideoDisplay component describe the width or height of the contained view.</p></blockquote>
<p>So, to get the properties of the view we need to delve deeper into VideoDisplay and use the mx_internal namespace. Even then, the ResizeEvent.RESIZE event is broadcast by VideoDisplay <strong>before</strong> it&#8217;s view dimensions (<strong>column B</strong>) have been updated to the new site.</p>
<p>In that previous article I observed that if, after each resize, I added an <code>Event.EXIT_FRAME</code> listener, I could guarantee that the VideoDisplay&#8217;s view had been sized by the time it was called. I observed that the same is true in Flex 4. However <code>EXIT_FRAME</code> didn&#8217;t feel like the right place to be doing this. So with a closer look at the component life cycle we can see that handling the <code>FlexEvent.UPDATE_COMPLETE</code> event is more appropriate. <strong>Column C </strong>shows the view&#8217;s width/height after <code>UPDATE_COMPLETE</code> has been broadcast. It colours red when a value  disagrees with column B (<code>RESIZE</code>). And so, it is column C that contains the values we want to use while managing our overlay.</p>
<div>
<object id="f4VideoDisplaySample1" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="470" height="300"><param name="allowFullScreen" value="true" /><param name="base" value="." /><param name="src" value="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/bin-release/VideoDisplayF4Sample1.swf" /><!--[if !IE]>--><br />
<object width="470" height="300" base="." allowfullscreen="true" data="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/bin-release/VideoDisplayF4Sample1.swf" type="application/x-shockwave-flash"><br />
<!--<![endif]--><br />
<img src="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/sample1-snapshot.jpg" alt="Sample 1 : Comparing width/height after resize, then updateComplete" /><br />
<!--[if !IE]>--><br />
</object><br />
<!--<![endif]--><br />
</object></div>
<p><script type="text/javascript">// <![CDATA[
swfobject.registerObject("f4VideoDisplaySample1", "10.0.0", "/wp-content/swfobject_2_2/expressInstall.swf");
// ]]&gt;</script></p>
<p>Using this information and Flex 4&#8242;s new component and skinning architecture, we can build quick and simple to use video overlay component rather than messing about with external listeners and calculating positions as we did in the previous Flex 3 examples.</p>
<p>Reviewing what Flex 4 includes &#8216;out of the box&#8217;&#8230;</p>
<ul>
<li><code><a title="VideoDisplay reference" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/VideoDisplay.html" target="_blank">VideoDisplay</a></code> : a non-skinable component that wraps an osmf &#8216;view&#8217;. It translates much of the osmf api and events to what we are accustomed to with Flex 3.</li>
<li><code><a title="VideoPlayer reference" href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/VideoPlayer.html" target="_blank">VideoPlayer</a></code> : A skinable component provides hooks for skin parts. A required part is an instance of VideoDisplay. The others are the buttons and controls we&#8217;d normally expect when giving the user control of the video.</li>
</ul>
<p>The VideoPlayer and it&#8217;s skin are overkill for this example, so we&#8217;ll create something far simpler&#8230;</p>
<ul>
<li><code>VideoDisplayOverlayContainer</code> : A container component who&#8217;s children will overlay a VideoDisplay</li>
<li><code>VideoDisplayOverlayContainerSkin</code> : A simple skin, providing the required videoDisplay skin part.</li>
</ul>
<p>This way, overlaying the video is as simple as giving the container some child components and a layout (defaults to basic layout). In the example that follows we overlay a label instance to each of the four corners and the centre of the view&#8230;</p>
<p><code></p>
<pre>&lt;components:VideoDisplayOverlayContainer
    id     ="videoDisplayContainer"
    source ="VideoSampleForFlex.mp4"
    width  ="100%"
    height ="100%" 	&gt;
    &lt;s:Label text="A" top="2" left="2" backgroundColor="0xffffff" backgroundAlpha="0.4" /&gt;
    &lt;s:Label text="B" top="2" right="2" backgroundColor="0xffffff" backgroundAlpha="0.4"  /&gt;
    &lt;s:Label text="C" bottom="2" left="2" backgroundColor="0xffffff" backgroundAlpha="0.4"  /&gt;
    &lt;s:Label text="D" bottom="2" right="2" backgroundColor="0xffffff" backgroundAlpha="0.4"  /&gt;
    &lt;s:Label text="O" verticalCenter="0" horizontalCenter="0" backgroundColor="0xffffff" backgroundAlpha="0.4"  /&gt;
&lt;/components:VideoDisplayOverlayContainer&gt;</pre>
<p></code></p>
<div>
<object id="f4VideoDisplaySample2" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="470" height="300"><param name="allowFullScreen" value="true" /><param name="base" value="." /><param name="src" value="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/bin-release/VideoDisplayF4Sample2.swf" /><!--[if !IE]>--><br />
<object width="470" height="300" base="." allowfullscreen="true" data="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/bin-release/VideoDisplayF4Sample2.swf" type="application/x-shockwave-flash"><br />
<!--<![endif]--><br />
<img src="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/sample2-snapshot.jpg" alt="Sample 2 : Overlay container component"/><br />
<!--[if !IE]>--><br />
</object><br />
<!--<![endif]--><br />
</object></div>
<p><script type="text/javascript">// <![CDATA[
swfobject.registerObject("f4VideoDisplaySample2", "10.0.0", "/wp-content/swfobject_2_2/expressInstall.swf");
// ]]&gt;</script></p>
<p><a title="Sample 2 source" href="/wp-content/code-samples/Flex4SparkVideoDisplayOverlaySamples/bin-release/srcview/index2.html" target="_blank">View source</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creacog.co.uk/2010/04/28/flex-4-spark-videodisplay-measure-overlay-skin/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>my first Flex 4 spark : component + skin = ResizeableTitleWindow</title>
		<link>http://blog.creacog.co.uk/2010/03/20/my-first-flex-4-spark-component-skin-resizeabletitlewindow/</link>
		<comments>http://blog.creacog.co.uk/2010/03/20/my-first-flex-4-spark-component-skin-resizeabletitlewindow/#comments</comments>
		<pubDate>Sat, 20 Mar 2010 01:15:27 +0000</pubDate>
		<dc:creator>creacog</dc:creator>
				<category><![CDATA[Flash Builder]]></category>
		<category><![CDATA[Flash Catalyst]]></category>
		<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Spark components]]></category>

		<guid isPermaLink="false">http://blog.creacog.co.uk/?p=324</guid>
		<description><![CDATA[With Flex 4 having been in beta for ages and hopefully soon to be released, it really was time I started to get my head around the spark components and how to approach to skinning them. Rather starting off with the usual button, I thought I&#8217;d kick off with getting a ResizeableTitleWindow going. Of course [...]]]></description>
			<content:encoded><![CDATA[<p>With Flex 4 having been in beta for ages and hopefully soon to be released, it really was time I started to get my head around the spark components and how to approach to skinning them. Rather starting off with the usual <a title="WRITING A SIMPLE BUTTON SKIN" href="http://www.adobe.com/devnet/flex/articles/flex4_skinning_02.html" target="_blank">button</a>, I thought I&#8217;d kick off with getting a ResizeableTitleWindow going. Of course a few others have already created variants. I think everyone using Flex at some point needs a resizeable version of TitleWindow. To that end, looking at the <a title="Spark TitleWindow Functional and Design Specification" href="http://opensource.adobe.com/wiki/display/flexsdk/Spark+TitleWindow#SparkTitleWindow-BFeatures" target="_blank">TitleWindow specification page of the Flex 4 wiki</a>, clearly Adobe planned on implementing resize behaviour on the TitleWindow. It doesn&#8217;t seem to be implemented yet. So in the meantime my version is as close as I think I can get to that specification.</p>
<p>The end result (view source enabled):</p>
<div style="border: 1px solid #000; width: 400px; height: 300px;"><object id="ResizeableTitleWindowSample" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="300"><param name="allowFullScreen" value="true" /><param name="base" value="." /><param name="allowfullscreen" value="true" /><param name="src" value="/wp-content/code-samples/Flex4SparkResizeableTitleWindow/r10/bin-release/Main.swf" /><!--[if !IE]>--><object width="400" height="300" base="." allowfullscreen="true" data="/wp-content/code-samples/Flex4SparkResizeableTitleWindow/r10/bin-release/Main.swf" type="application/x-shockwave-flash"><!--<![endif]--><!--[if !IE]>--></object><!--<![endif]--></object>
</div>
<p><script type="text/javascript">// <![CDATA[
swfobject.registerObject("ResizeableTitleWindowSample", "10.0.32", "/wp-content/swfobject_2_2/expressInstall.swf");
// ]]&gt;</script></p>
<ul>
<li><a title="View source for ResizeableTitleWindowSample in a new window" href="http://blog.creacog.co.uk/wp-content/code-samples/Flex4SparkResizeableTitleWindow/r10/bin-release/srcview/index.html" target="_blank">View source</a></li>
<li><a title="Download ResizeableTitleWindow source files (zip archive)" href="http://blog.creacog.co.uk/wp-content/code-samples/Flex4SparkResizeableTitleWindow/r10/bin-release/srcview/0000-creacog-ResizeableTItleWindow.zip">Download source zip</a></li>
<li><a title="Download resizeHandle Flash Catalyst project" href="http://blog.creacog.co.uk/wp-content/code-samples/Flex4SparkResizeableTitleWindow/r10/resizeHandle.fxp.zip">Download resizeHandle.fxp (Flash Catalyst project)</a></li>
<li><a title="Download resizeHandle.fxpl" href="http://blog.creacog.co.uk/wp-content/code-samples/Flex4SparkResizeableTitleWindow/r10/resizeHandle.fxpl.zip">Download resizeHandle.fxpl (Flash Catalyst library)</a></li>
</ul>
</div>
<h3>My 1st spark skin</h3>
<p>In the running example above, window &#8216;A&#8217; is a normal instance of <a title="spark.components.TitleWindow " href="http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/spark/components/TitleWindow.html?filter_flex=4&amp;filter_flashplayer=10&amp;filter_air=1.5" target="_blank">spark.components.TitleWindow</a>. This leads me to my first spark skin. If you are viewing on a windows or linux platform it won&#8217;t look any different from normal. In that case it is simply using spark.skins.spark.TitleWindowSkin. However if you are viewing on a Mac you&#8217;ll notice that the close button is located at the left of the title bar rather than the right. This is where a Mac user will expect it to be &#8211; but the default in Flex is currently to the right, no matter what platform. This was achieved through the most basic technique of skinning a spark component : clone an existing skin, adapt it and apply it. To that end, spark.skins.spark.TitleWindowSkin was cloned to creacog.spark.skins.TitleWindowMacSkin, and a couple of lines changed swap around the closeButton and title. We switch skins if we are on the mac platform by loading the compiled Mac style sheet in the preinitialize handler of main.mxml.</p>
<p>This technique of cloning is one thing that initially feels slightly wrong with spark. It leads to a lot of duplicate code which is something developers normally do their best to avoid. The reasoning seems mainly to facilitate Flash Catalyst workflow, where skins are predominantly the domain of interaction designers for whom duplication is the norm and code re-use doesn&#8217;t really figure. However until and unless Flash Catalyst matures into a product that can support round-trip editing, there&#8217;s a good chance that developers will be making a lot of use of diff tools and duplicate code across skins is something we&#8217;ll probably just get used to. The subject has been discussed in detail in a number of other blogs and their comments:</p>
<ul>
<li><a title="Flex 4 skinning ignores developer needs" rel="bookmark" href="http://www.flexjunk.com/2009/08/03/flex-4-skinning-ignores-developer-needs/" target="_blank">Flex 4 skinning ignores developer needs</a></li>
<li><a title="Using Flex 4 Skin Inheritance To Make PictureButton Component" href="http://flexblog.faratasystems.com/2010/02/17/using-flex-4-skin-inheritance-to-make-picturebutton-component" target="_blank">Using Flex 4 Skin Inheritance To Make PictureButton Component</a></li>
</ul>
<h3>Implementing and skinning ResizeableTitleWindow</h3>
<p>We now need to know a little more about the mechanics of spark skinning. I must admit having previously read some blogs and watched some video posts of how simple spark skinning is &#8211; and I got it until sitting in-front of an empty editor scratching my head &#8211; where to begin? The key thing that crystallised it for me was to read the <a title="Introducing skinning in Flex 4" href="http://www.adobe.com/devnet/flex/articles/flex4_skinning_03.html" target="_blank">skinning contract</a>.</p>
<p>So, first was to create the component class. This extends spark.components.TitleWindow. It adds a new optional skin part of resizeHandle of type UIComponent. Essentially we need something the user can click on no matter what it&#8217;s appearance. creacog.spark.events.TitleWindowBoundsEvent was created extending spark.events.TitleWindowBoundsEvent with the new event constants for resizing. Using the creacog package is the main deviation from the specification &#8211; for obvious reasons.</p>
<p>Catalyst was used to create the ResizeHandleSkin. A simple custom component with two states: up and over. It has a semi-transparent white background that transitions it&#8217;s alpha on mouse over. Importing ResizeHandle.fxpl into the flex project resulted in slightly odd packaging. Simply moving ResizeHandle.mxml to the creacog.spark.skins package brought it into structure consistent with the rest of the project.</p>
<p>spark.skins.spark.TitleWindowSkin was again cloned, this time to creacog.spark.skins.ResizeableTitleWindowSkin. To that 3 new lines is all that was required to add an instance of the resizeHandle skin part &#8211; positioned front-most and at the bottom right corner. It could be any size and positioned anywhere, but the logic behind resize adjusts the width and height of the component, leaving it&#8217;s x and y untouched.</p>
<p>creacog.spark.skins.ResizeableTitleWindowMacSkin is a further clone, this time with the closeButton skin part positioned to the left for mac users.</p>
<p>Finally we use styles (being careful of  the new namespace syntax) to the  notify the flex framework to use creacog.spark.skins.ResizeableTitleWindowSkin (and substitute creacog.spark.skins.ResizeableTitleWindowMacSkin on the Mac) whenever a ResizeableTitleWindow instance is drawn. If we omitted this step, the ResizeableTitleWindow instance would be created, but it would fall back to using the TitleWindowSkin which does not include the resizeHandle skin part and therefore the resizing functionality would be ignored.</p>
<h3>Summing up</h3>
<p>This new approach to skinning components feels far superior to what we have been used to in Flex 3. I&#8217;m slightly scared that the workflow from designer  via catalyst could result in inflexible skins (at least in the short term), as post-production work is required of the developer if the skin is intended to take on runtime styling for example. Lack of any sign of round-trip capability means skin production is currently one way from catalyst. i.e. tweaks or changes within catalyst will create a new output and it will be for the developer to merge the changes with additions s/he may have implemented on previous skins.</p>
<p>Looking forward to getting going on some real flex 4 projects.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.creacog.co.uk/2010/03/20/my-first-flex-4-spark-component-skin-resizeabletitlewindow/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

