<?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>Flex Examples &#187; States</title>
	<atom:link href="http://blog.flexexamples.com/category/states/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.flexexamples.com</link>
	<description>Just a bunch of Adobe Flex Examples</description>
	<lastBuildDate>Wed, 26 Jan 2011 18:09:51 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Hiding specific items in a data provider based on the current application state in Flex Gumbo</title>
		<link>http://blog.flexexamples.com/2009/02/24/hiding-specific-items-in-a-data-provider-based-on-the-current-application-state-in-flex-gumbo/</link>
		<comments>http://blog.flexexamples.com/2009/02/24/hiding-specific-items-in-a-data-provider-based-on-the-current-application-state-in-flex-gumbo/#comments</comments>
		<pubDate>Wed, 25 Feb 2009 07:37:46 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta]]></category>
		<category><![CDATA[States]]></category>
		<category><![CDATA[currentState]]></category>
		<category><![CDATA[excludeFrom]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[includeIn]]></category>
		<category><![CDATA[state]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2009/02/24/hiding-specific-items-in-a-data-provider-based-on-the-current-application-state-in-flex-gumbo/</guid>
		<description><![CDATA[<p>The following example shows how you can toggle specific strings based on the Flex Gumbo application&#8217;s current state by using the includeIn and excludeFrom attributes on the String object.</p> <p>For more information see <a href="http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/">&#8220;Exploring the new states syntax in Flex Gumbo&#8221;</a> and the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax">&#8220;Enhanced States Syntax &#8211; Functional and Design Specification&#8221;</a> page at [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can toggle specific strings based on the Flex Gumbo application&#8217;s current state by using the <code>includeIn</code> and <code>excludeFrom</code> attributes on the String object.</p>
<p>For more information see <a href="http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/">&#8220;Exploring the new states syntax in Flex Gumbo&#8221;</a> and the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax">&#8220;Enhanced States Syntax &#8211; Functional and Design Specification&#8221;</a> page at opensource.adobe.com.</p>
<p>Full code after the jump.</p>
<p><span id="more-977"></span></p>
<p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see <a href="http://blog.flexexamples.com/2008/08/02/using-the-beta-gumbo-sdk-in-flex-builder-3/">&#8220;Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</p>
<p class="download"><a href="">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2009/02/24/hiding-specific-items-in-a-data-provider-based-on-the-current-application-state-in-flex-gumbo/ --&gt;
&lt;FxApplication name="String_includeIn_test"
        xmlns="http://ns.adobe.com/mxml/2009"
        backgroundColor="white"&gt;

    &lt;states&gt;
        &lt;State name="one" /&gt;
        &lt;State name="two" /&gt;
        &lt;State name="three" /&gt;
    &lt;/states&gt;

    &lt;ApplicationControlBar&gt;
        &lt;Form styleName="plain"&gt;
            &lt;FormItem label="currentState:"&gt;
                &lt;Label text="{currentState}" /&gt;
            &lt;/FormItem&gt;
            &lt;FormItem direction="horizontal"&gt;
                &lt;FxButton label="State one"
                        click="currentState='one';" /&gt;
                &lt;FxButton label="State two"
                        click="currentState='two';" /&gt;
                &lt;FxButton label="State three"
                        click="currentState='three';" /&gt;
            &lt;/FormItem&gt;
        &lt;/Form&gt;
    &lt;/ApplicationControlBar&gt;

    &lt;FxList id="list"
            horizontalCenter="0"
            bottom="40"&gt;
        &lt;dataProvider&gt;
            &lt;ArrayCollection&gt;
                &lt;String&gt;1. The&lt;/String&gt;
                &lt;String&gt;2. Quick&lt;/String&gt;
                &lt;String&gt;3. Brown&lt;/String&gt;
                &lt;String includeIn="one"&gt;4. Fox&lt;/String&gt;
                &lt;String includeIn="two"&gt;5. Jumps&lt;/String&gt;
                &lt;String includeIn="one,two"&gt;6. Over&lt;/String&gt;
                &lt;String excludeFrom="one"&gt;7. The&lt;/String&gt;
                &lt;String excludeFrom="two"&gt;8. Lazy&lt;/String&gt;
                &lt;String excludeFrom="one,two"&gt;9. Dog&lt;/String&gt;
            &lt;/ArrayCollection&gt;
        &lt;/dataProvider&gt;
    &lt;/FxList&gt;

&lt;/FxApplication&gt;
</pre>
<p class="alert">This entry is based on a beta version of the Flex Gumbo SDK and therefore is very likely to change as development of the Flex SDK continues. The API can (and will) change causing examples to possibly not compile in newer versions of the Flex Gumbo SDK.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Hiding specific items in a data provider based on the current application state in Flex Gumbo on FlexExamples.com',url: 'http://blog.flexexamples.com/2009/02/24/hiding-specific-items-in-a-data-provider-based-on-the-current-application-state-in-flex-gumbo/',contentID: 'post-977',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'currentState,excludeFrom,Gumbo,includeIn,state',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2009/02/24/hiding-specific-items-in-a-data-provider-based-on-the-current-application-state-in-flex-gumbo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Exploring the new states syntax in Flex Gumbo</title>
		<link>http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/</link>
		<comments>http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/#comments</comments>
		<pubDate>Thu, 14 Aug 2008 06:37:27 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[beta]]></category>
		<category><![CDATA[States]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[includeIn]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/</guid>
		<description><![CDATA[<p>The following examples show the new enhanced state syntax in the beta Flex Gumbo SDK. For more information and examples on the new state syntax, see the spec at <a href="http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax">http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax</a>.</p> <p>Full code after the jump.</p> <p></p> <p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed [...]]]></description>
			<content:encoded><![CDATA[<p>The following examples show the new enhanced state syntax in the beta Flex Gumbo SDK. For more information and examples on the new state syntax, see the spec at <a href="http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax">http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax</a>.</p>
<p>Full code after the jump.</p>
<p><span id="more-743"></span></p>
<p class="alert">To use the following code, you must have Flash Player 10 and a Flex Gumbo SDK installed in your Flex Builder 3. For more information on downloading and installing the Gumbo SDK into Flex Builder 3, see <a href="http://blog.flexexamples.com/2008/08/02/using-the-beta-gumbo-sdk-in-flex-builder-3/">&#8220;Using the beta Gumbo SDK in Flex Builder 3&#8243;</a>.</p>
<p>The following example shows how you can set specific fill color for a rectangle for each state using dot-syntax on an attribute in an MXML tag:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/srcview/source/main.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/ --&gt;
&lt;Application xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        layout="flex.layout.BasicLayout"&gt;

    &lt;states&gt;
        &lt;State name="state1" /&gt;
        &lt;State name="state2" /&gt;
        &lt;State name="state3" /&gt;
    &lt;/states&gt;

    &lt;mx:HBox left="10" top="10"&gt;
        &lt;Button label="State 1 (red)"
                click="currentState='state1';" /&gt;
        &lt;Button label="State 2 (green)"
                click="currentState='state2';" /&gt;
        &lt;Button label="State 3 (blue)"
            click="currentState='state3';" /&gt;
    &lt;/mx:HBox&gt;

    &lt;Rect id="rect"
            width="100"
            height="100"
            horizontalCenter="0"
            verticalCenter="0"&gt;
        &lt;fill&gt;
            &lt;SolidColor color.state1="red"
                    color.state2="haloGreen"
                    color.state3="haloBlue" /&gt;
        &lt;/fill&gt;
    &lt;/Rect&gt;

&lt;/Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/main.html" width="100%" height="200"></iframe></p>
<p>The following example shows how you can use the same dot syntax on the MXML tag directly to set a different fill type (SolidColor, LinearGradient, BitmapFill) on a rectangle:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/srcview/source/main2.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/ --&gt;
&lt;Application xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        layout="flex.layout.BasicLayout"&gt;

    &lt;states&gt;
        &lt;State name="state1" /&gt;
        &lt;State name="state2" /&gt;
        &lt;State name="state3" /&gt;
    &lt;/states&gt;

    &lt;mx:HBox left="10" top="10"&gt;
        &lt;Button label="State 1 (SolidColor)"
                click="currentState='state1';" /&gt;
        &lt;Button label="State 2 (LinearGradient)"
                click="currentState='state2';" /&gt;
        &lt;Button label="State 3 (BitmpFill)"
            click="currentState='state3';" /&gt;
    &lt;/mx:HBox&gt;

    &lt;Rect id="rect"
            width="100"
            height="100"
            horizontalCenter="0"
            verticalCenter="0"&gt;
        &lt;fill.state1&gt;
            &lt;SolidColor color="red" /&gt;
        &lt;/fill.state1&gt;
        &lt;fill.state2&gt;
            &lt;LinearGradient&gt;
                &lt;GradientEntry color="red" /&gt;
                &lt;GradientEntry color="haloOrange" /&gt;
                &lt;GradientEntry color="yellow" /&gt;
                &lt;GradientEntry color="haloGreen" /&gt;
                &lt;GradientEntry color="haloBlue" /&gt;
            &lt;/LinearGradient&gt;
        &lt;/fill.state2&gt;
        &lt;fill.state3&gt;
            &lt;BitmapFill source="@Embed('flex_logo.jpg')" /&gt;
        &lt;/fill.state3&gt;
    &lt;/Rect&gt;

&lt;/Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/main2.html" width="100%" height="200"></iframe></p>
<p>The following example shows how you can include or exclude display list items by specifying the <code>includeIn</code> attribute in the MXML tag:</p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/srcview/source/main3.mxml.html">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/ --&gt;
&lt;Application xmlns="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library:adobe/flex/halo"
        layout="flex.layout.BasicLayout"&gt;

    &lt;states&gt;
        &lt;State name="state1" /&gt;
        &lt;State name="state2" /&gt;
        &lt;State name="state3" /&gt;
    &lt;/states&gt;

    &lt;mx:HBox left="10" top="10"&gt;
        &lt;Button label="State 1 (Rect)"
                click="currentState='state1';" /&gt;
        &lt;Button label="State 2 (Ellipse)"
                click="currentState='state2';" /&gt;
        &lt;Button label="State 3 (Path)"
            click="currentState='state3';" /&gt;
    &lt;/mx:HBox&gt;

    &lt;Rect id="rect"
            width="100"
            height="100"
            horizontalCenter="0"
            verticalCenter="0"
            includeIn="state1"&gt;
        &lt;fill&gt;
            &lt;SolidColor color="red" /&gt;
        &lt;/fill&gt;
    &lt;/Rect&gt;

    &lt;Ellipse id="ellipse"
            width="100"
            height="100"
            horizontalCenter="0"
            verticalCenter="0"
            includeIn="state2"&gt;
        &lt;fill&gt;
            &lt;SolidColor color="red" /&gt;
        &lt;/fill&gt;
    &lt;/Ellipse&gt;

    &lt;Path id="path"
            data="M 0 0 L 100 100 Z M 0 100 L 100 0 Z"
            horizontalCenter="0"
            verticalCenter="0"
            includeIn="state3"&gt;
        &lt;stroke&gt;
            &lt;SolidColorStroke color="red" weight="10" /&gt;
        &lt;/stroke&gt;
    &lt;/Path&gt;

&lt;/Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Gumbo_States_test/bin/main3.html" width="100%" height="200"></iframe></p>
<p>These are just a few of the many things you can do with the new, enhanced state syntax in Flex Gumbo. For more examples, see the the <a href="http://opensource.adobe.com/wiki/display/flexsdk/Enhanced+States+Syntax">Enhanced States Syntax &#8211; Functional and Design Specification</a> document on the <a href="http://opensource.adobe.com/">opensource.adobe.com</a> site.</p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Exploring the new states syntax in Flex Gumbo on FlexExamples.com',url: 'http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/',contentID: 'post-743',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'Gumbo,includeIn',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2008/08/13/exploring-the-new-states-syntax-in-flex-gumbo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating view states in a Flex application</title>
		<link>http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/</link>
		<comments>http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/#comments</comments>
		<pubDate>Sat, 06 Oct 2007 05:59:18 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[AddChild]]></category>
		<category><![CDATA[States]]></category>
		<category><![CDATA[state]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/</guid>
		<description><![CDATA[<p>The following example shows how you can create different view states in a Flex application by using the &#60;mx:states /&#62; and &#60;mx:State /&#62; tags.</p> <p>Full code after the jump.</p> <p></p> <p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_currentState_test/main.mxml">View MXML</a></p> &#60;?xml version="1.0" encoding="utf-8"?&#62; &#60;!-- http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/ --&#62; &#60;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="middle" backgroundColor="white"&#62; &#60;mx:states&#62; &#60;mx:State name="login"&#62; &#60;mx:AddChild&#62; &#60;mx:Form id="loginForm"&#62; &#60;mx:FormHeading label="Login" /&#62; &#60;mx:FormItem [...]]]></description>
			<content:encoded><![CDATA[<p>The following example shows how you can create different view states in a Flex application by using the &lt;mx:states /&gt; and &lt;mx:State /&gt; tags.</p>
<p>Full code after the jump.</p>
<p><span id="more-221"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_currentState_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:states&gt;
        &lt;mx:State name="login"&gt;
            &lt;mx:AddChild&gt;
                &lt;mx:Form id="loginForm"&gt;
                    &lt;mx:FormHeading label="Login" /&gt;
                    &lt;mx:FormItem label="Username:"&gt;
                        &lt;mx:TextInput id="log_username" /&gt;
                    &lt;/mx:FormItem&gt;
                    &lt;mx:FormItem label="Password:"&gt;
                        &lt;mx:TextInput id="log_password"
                                displayAsPassword="true" /&gt;
                    &lt;/mx:FormItem&gt;
                    &lt;mx:FormItem&gt;
                        &lt;mx:Button label="Login" /&gt;
                    &lt;/mx:FormItem&gt;
                &lt;/mx:Form&gt;
            &lt;/mx:AddChild&gt;
        &lt;/mx:State&gt;
        &lt;mx:State name="register"&gt;
            &lt;mx:AddChild&gt;
                &lt;mx:Form id="registerForm"&gt;
                    &lt;mx:FormHeading label="Register" /&gt;
                    &lt;mx:FormItem label="Username:"&gt;
                        &lt;mx:TextInput id="reg_username" /&gt;
                    &lt;/mx:FormItem&gt;
                    &lt;mx:FormItem label="Password:"&gt;
                        &lt;mx:TextInput id="reg_password1"
                                displayAsPassword="true" /&gt;
                    &lt;/mx:FormItem&gt;
                    &lt;mx:FormItem label="Confirm password:"&gt;
                        &lt;mx:TextInput id="reg_password2"
                                displayAsPassword="true" /&gt;
                    &lt;/mx:FormItem&gt;
                    &lt;mx:FormItem&gt;
                        &lt;mx:Button label="Register" /&gt;
                    &lt;/mx:FormItem&gt;
                &lt;/mx:Form&gt;
            &lt;/mx:AddChild&gt;
        &lt;/mx:State&gt;
    &lt;/mx:states&gt;

    &lt;mx:transitions&gt;
        &lt;mx:Transition id="loginTransition"
                fromState="*"
                toState="login"&gt;
            &lt;mx:WipeDown target="{loginForm}"/&gt;
        &lt;/mx:Transition&gt;
        &lt;mx:Transition id="registerTransition"
                fromState="*"
                toState="register"&gt;
            &lt;mx:WipeDown target="{registerForm}"/&gt;
        &lt;/mx:Transition&gt;
    &lt;/mx:transitions&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.events.ItemClickEvent;

            private function toggleButtonBar_itemClick(evt:ItemClickEvent):void {
                currentState = evt.item.data;
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:Array id="dp"&gt;
        &lt;mx:Object data="" label="Default state" /&gt;
        &lt;mx:Object data="login" label="Login" /&gt;
        &lt;mx:Object data="register" label="Register" /&gt;
    &lt;/mx:Array&gt;

    &lt;mx:ApplicationControlBar dock="true"&gt;
        &lt;mx:ToggleButtonBar id="toggleButtonBar"
                dataProvider="{dp}"
                itemClick="toggleButtonBar_itemClick(event);" /&gt;
    &lt;/mx:ApplicationControlBar&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/Application_currentState_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/Application_currentState_test/bin/main.html" width="100%" height="300"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Creating view states in a Flex application on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/',contentID: 'post-221',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'state',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/10/05/creating-view-states-in-a-flex-application/feed/</wfw:commentRss>
		<slash:comments>20</slash:comments>
		</item>
		<item>
		<title>Toggling a Flex container&#8217;s visibility using states</title>
		<link>http://blog.flexexamples.com/2007/08/24/toggling-a-flex-containers-visibility-using-states/</link>
		<comments>http://blog.flexexamples.com/2007/08/24/toggling-a-flex-containers-visibility-using-states/#comments</comments>
		<pubDate>Fri, 24 Aug 2007 14:10:36 +0000</pubDate>
		<dc:creator>Peter deHaan</dc:creator>
				<category><![CDATA[AddChild]]></category>
		<category><![CDATA[Parallel]]></category>
		<category><![CDATA[States]]></category>
		<category><![CDATA[Transition]]></category>
		<category><![CDATA[VBox]]></category>
		<category><![CDATA[WipeDown]]></category>
		<category><![CDATA[currentState]]></category>
		<category><![CDATA[state]]></category>
		<category><![CDATA[transitions]]></category>

		<guid isPermaLink="false">http://blog.flexexamples.com/2007/08/24/toggling-a-flex-containers-visibility-using-states/</guid>
		<description><![CDATA[<p>In a previous post, <a href="http://blog.flexexamples.com/2007/08/23/toggling-a-flex-containers-visibility/">&#8220;Toggling a Flex container&#8217;s visibility&#8221;</a>, we looked at toggling a VBox container&#8217;s visibility by setting both the visible property and includeInLayout property. While the approach felt a little crude, we can build the same thing using the much more powerful view states. What are view states and how do we [...]]]></description>
			<content:encoded><![CDATA[<p>In a previous post, <a href="http://blog.flexexamples.com/2007/08/23/toggling-a-flex-containers-visibility/">&#8220;Toggling a Flex container&#8217;s visibility&#8221;</a>, we looked at toggling a VBox container&#8217;s visibility by setting both the <code>visible</code> property and <code>includeInLayout</code> property. While the approach felt a little crude, we can build the same thing using the much more powerful view states. What are view states and how do we use them? Well, if you&#8217;re new to states, this should clear everything up: <a href="http://www.adobe.com/devnet/flex/quickstart/defining_state_transitions/">&#8220;Adobe &#8211; Flex Quick Start Basics: Creating States&#8221;</a>.</p>
<p>Now, with that out of the way, lets look at some code and a basic example.</p>
<p>Full code after the jump.</p>
<p><span id="more-118"></span></p>
<p class="download"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_states_test/main.mxml">View MXML</a></p>
<pre class="code">
&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;!-- http://blog.flexexamples.com/2007/08/24/toggling-a-flex-containers-visibility-using-states/ --&gt;
&lt;mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white"&gt;

    &lt;mx:transitions&gt;
        &lt;mx:Transition fromState="*" toState="*"&gt;
            &lt;mx:Parallel targets="{[vbox2]}"&gt;
                &lt;mx:WipeDown /&gt;
                &lt;mx:Fade /&gt;
            &lt;/mx:Parallel&gt;
        &lt;/mx:Transition&gt;
    &lt;/mx:transitions&gt;

    &lt;mx:states&gt;
        &lt;mx:State name="expanded"&gt;
            &lt;mx:AddChild relativeTo="{vbox1}" position="after"&gt;
                &lt;mx:VBox id="vbox2"
                        width="120"
                        height="100%"
                        backgroundColor="haloGreen"&gt;
                    &lt;mx:Label text="VBox 2" /&gt;
                &lt;/mx:VBox&gt;
            &lt;/mx:AddChild&gt;
        &lt;/mx:State&gt;
    &lt;/mx:states&gt;

    &lt;mx:Style&gt;
        VBox {
            paddingLeft: 10;
            paddingRight: 10;
            paddingTop: 10;
            paddingBottom: 10;
        }
    &lt;/mx:Style&gt;

    &lt;mx:Script&gt;
        &lt;![CDATA[
            import mx.effects.easing.*;

            [Bindable]
            [Embed(source="assets/help.png")]
            private var helpIcon:Class;

            private function toggleExpanded():void {
                switch (currentState) {
                    case "expanded":
                        currentState = "";
                        break;
                    default:
                        currentState = "expanded";
                        break;
                }
            }
        ]]&gt;
    &lt;/mx:Script&gt;

    &lt;mx:HBox width="100%" height="100%"&gt;
        &lt;mx:VBox id="vbox1"
                width="120"
                height="100%"
                backgroundColor="haloOrange"&gt;
            &lt;mx:Label text="VBox 1" /&gt;
            &lt;mx:Button label="Help"
                       icon="{helpIcon}"
                    click="toggleExpanded()" /&gt;
        &lt;/mx:VBox&gt;

        &lt;mx:VBox id="vbox3"
                width="100%"
                height="100%"
                backgroundColor="haloBlue"&gt;
            &lt;mx:Label text="VBox 3" /&gt;
        &lt;/mx:VBox&gt;
    &lt;/mx:HBox&gt;

&lt;/mx:Application&gt;
</pre>
<p class="information"><a href="http://blog.flexexamples.com/wp-content/uploads/VBox_states_test/bin/srcview/index.html">View source</a> is enabled in the following example.</p>
<p><iframe src="http://blog.flexexamples.com/wp-content/uploads/VBox_states_test/bin/main.html" width="100%" height="250"></iframe></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Toggling a Flex container\&#039;s visibility using states on FlexExamples.com',url: 'http://blog.flexexamples.com/2007/08/24/toggling-a-flex-containers-visibility-using-states/',contentID: 'post-118',code: 'Pete9667',suggestNotebook: 'FlexExamples',suggestTags: 'currentState,state,transitions',providerName: 'FlexExamples.com',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-remember.png" class="evernoteSiteMemoryButton" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div>]]></content:encoded>
			<wfw:commentRss>http://blog.flexexamples.com/2007/08/24/toggling-a-flex-containers-visibility-using-states/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

