<?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>SmartLogic Solutions Blog &#187; Login Form</title>
	<atom:link href="http://blog.smartlogicsolutions.com/tag/login-form/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.smartlogicsolutions.com</link>
	<description>News and updates from the people at SmartLogic Solutions</description>
	<lastBuildDate>Tue, 30 Nov 2010 21:39:14 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Flex 4 Login Form Component</title>
		<link>http://blog.smartlogicsolutions.com/2009/05/28/flex-4-login-form-component/</link>
		<comments>http://blog.smartlogicsolutions.com/2009/05/28/flex-4-login-form-component/#comments</comments>
		<pubDate>Thu, 28 May 2009 16:59:08 +0000</pubDate>
		<dc:creator>Greg Jastrab</dc:creator>
				<category><![CDATA[Flex 4]]></category>
		<category><![CDATA[Greg Jastrab]]></category>
		<category><![CDATA[Gumbo]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Login Form]]></category>

		<guid isPermaLink="false">http://blog.smartlogicsolutions.com/?p=665</guid>
		<description><![CDATA[It&#8217;s been a while since I&#8217;ve gotten to blog about Flex 4/Gumbo, and with some exciting news likely coming tomorrow I figured it was time to get back on track. I wanted to think of an example of something that may be frequently used across Flex/AIR projects that will greatly benefit from the Flex 4 [...]]]></description>
			<content:encoded><![CDATA[<p>It&#8217;s been a while since I&#8217;ve gotten to blog about Flex 4/Gumbo, and with some exciting news <a href="http://www.flashcamp.org/2009/05/27/flashcamp-san-francisco-is-in-two-days/">likely coming tomorrow</a> I figured it was time to get back on track.  I wanted to think of an example of something that may be frequently used across Flex/AIR projects that will greatly benefit from the Flex 4 architecture and a Login Form seemed like a good place to start.  So today we&#8217;ll review a <a href="http://github.com/gjastrab/flex4-login-form">Login Form component</a> I created in Flex 4.  Follow the link to checkout the code from GitHub.</p>
<p><b>NOTE:</b> This code was compiled using the 7297 revision of the <a href="http://opensource.adobe.com/svn/opensource/flex/sdk/trunk/">Gumbo SDK trunk</a>.<br />
<span id="more-665"></span><br />
The LoginForm component extends <a href="http://opensource.adobe.com/wiki/display/flexsdk/Gumbo+Skinning">SkinnableComponent</a> and defines the 3 states (<b>login</b>, <b>loggingIn</b>, and <b>loggedIn</b>) &#038; various skin parts.  Lets dive into the example skin for the component.</p>
<h3>com.smartlogicsolutions.skins.LoginFormSkin</h3>

<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;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&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:Skin</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span> <span style="color: #000066;">xmlns:s</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&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;Metadata<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    [HostComponent(&quot;com.smartlogicsolutions.components.LoginForm&quot;)]
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Metadata<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: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;login&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;loggingIn&quot;</span> <span style="color: #000066;">stateGroups</span>=<span style="color: #ff0000;">&quot;notLogin&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;loggedIn&quot;</span> <span style="color: #000066;">stateGroups</span>=<span style="color: #ff0000;">&quot;notLogin&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:VGroup<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:HGroup</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;">verticalAlign</span>=<span style="color: #ff0000;">&quot;middle&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:SimpleText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;loginFieldLabel&quot;</span> <span style="color: #000066;">fontWeight</span>=<span style="color: #ff0000;">&quot;bold&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:TextInput</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;loginField&quot;</span> <span style="color: #000066;">enabled.notLogin</span>=<span style="color: #ff0000;">&quot;false&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:HGroup<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:HGroup</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;">verticalAlign</span>=<span style="color: #ff0000;">&quot;middle&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:SimpleText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;passwordFieldLabel&quot;</span> <span style="color: #000066;">fontWeight</span>=<span style="color: #ff0000;">&quot;bold&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:TextInput</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;passwordField&quot;</span> <span style="color: #000066;">enabled.notLogin</span>=<span style="color: #ff0000;">&quot;false&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:HGroup<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:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;loginButton&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Login&quot;</span> <span style="color: #000066;">enabled.notLogin</span>=<span style="color: #ff0000;">&quot;false&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:SimpleText</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;loginMessage&quot;</span> <span style="color: #000066;">excludeFrom</span>=<span style="color: #ff0000;">&quot;login&quot;</span></span>
<span style="color: #009900;">                  <span style="color: #000066;">text</span>=<span style="color: #ff0000;">&quot;{hostComponent.loginMessageLabel}&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:VGroup<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:Skin<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The skin provides the essentials for a login form: labels, input boxes, a button, and a label to display what is going on.  This skin provides all of the skin parts the LoginForm may display.  Of course, the only things a login form <b>must</b> have are the input fields and a button, so these are the only required parts of the component, as seen in this excerpt of the LoginForm component:</p>
<h3>(excerpt) com.smartlogicsolutions.components.LoginForm</h3>

<div class="wp_syntax"><div class="code"><pre class="actionscript" style="font-family:monospace;"><span style="color: #66cc66;">&#91;</span>SkinPart<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> loginButton:<span style="color: #0066CC;">Button</span>;
&nbsp;
<span style="color: #66cc66;">&#91;</span>SkinPart<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> loginField:TextInput;
&nbsp;
<span style="color: #66cc66;">&#91;</span>SkinPart<span style="color: #66cc66;">&#93;</span>
<span style="color: #0066CC;">public</span> <span style="color: #000000; font-weight: bold;">var</span> passwordField:TextInput;</pre></div></div>

<p>The labels are all decorated as being optional with the <code>[SkinPart(required="false")]</code> metadata, so any custom skin you provide for the Login Form doesn&#8217;t have to include the labels if you don&#8217;t desire.</p>
<p>Once you click the login button, the component puts itself into the <b>loggingIn</b> state and an associated event is dispatched.  At this point you would call your service to execute the login, and eventually notify the form the result of the login action.  So as for now, in this version of the component, you&#8217;ll need to explicitly call <code>loginSucceeded()</code> or <code>loginFailed()</code> on the LoginForm instance to signal the result.</p>
<p>Since this is a Flex 4 component, and the view &#038; layout is decoupled from the LoginForm itself, it&#8217;s dead simple to re-purpose this component across various applications and apply drastically different styles and layouts for all of them.  And the only thing that needs to happen is creating another Skin, and specifying that skin when including the LoginForm in your application.  Look at the test application file that comes with this component to see how the skin is connected to the form:</p>
<h3>TestLoginApplication.mxml</h3>

<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;?xml</span> <span style="color: #000066;">version</span>=<span style="color: #ff0000;">&quot;1.0&quot;</span> <span style="color: #000066;">encoding</span>=<span style="color: #ff0000;">&quot;utf-8&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:Application</span> <span style="color: #000066;">xmlns</span>=<span style="color: #ff0000;">&quot;http://ns.adobe.com/mxml/2009&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">xmlns:s</span>=<span style="color: #ff0000;">&quot;library://ns.adobe.com/flex/spark&quot;</span></span>
<span style="color: #009900;">               <span style="color: #000066;">xmlns:sls</span>=<span style="color: #ff0000;">&quot;com.smartlogicsolutions.components.*&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;Script<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    private function enableButtons(doEnable:Boolean):void {
      btn.enabled = failBtn.enabled = doEnable;
    }
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/Script<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: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:VerticalLayout</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>
&nbsp;
  <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;sls:LoginForm</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;loginForm&quot;</span></span>
<span style="color: #009900;">                 <span style="color: #000066;">skinClass</span>=<span style="color: #ff0000;">&quot;com.smartlogicsolutions.skins.LoginFormSkin&quot;</span></span>
<span style="color: #009900;">                 <span style="color: #000066;">loginLabel</span>=<span style="color: #ff0000;">&quot;Login:&quot;</span> <span style="color: #000066;">loggedInMessage</span>=<span style="color: #ff0000;">&quot;Sweet, logged in!&quot;</span></span>
<span style="color: #009900;">                 <span style="color: #000066;">login</span>=<span style="color: #ff0000;">&quot;enableButtons(true)&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:HGroup<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:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;btn&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Set Login Success&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;loginForm.loginSucceeded(); enableButtons(false)&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:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;failBtn&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Set Login Failed&quot;</span> <span style="color: #000066;">enabled</span>=<span style="color: #ff0000;">&quot;false&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;loginForm.loginFailed(); enableButtons(false)&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:Button</span> <span style="color: #000066;">id</span>=<span style="color: #ff0000;">&quot;updateLoggingInMessage&quot;</span> <span style="color: #000066;">label</span>=<span style="color: #ff0000;">&quot;Update Logging In Message&quot;</span></span>
<span style="color: #009900;">              <span style="color: #000066;">click</span>=<span style="color: #ff0000;">&quot;loginForm.loggingInMessage = 'Trying to login'&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:HGroup<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:Application<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

<p>The <code>skinClass</code> property of the LoginForm component will register a skin with the component.  In the future, this component would be bundled into a SWC that would apply the skin I&#8217;ve provided by default, but for now you&#8217;ll need to explicitly apply a <code>skinClass</code> to the component.</p>
<p>I haven&#8217;t figured out how to properly embed Flash 10 SWFs in wordpress w/o breaking the page for users that don&#8217;t have it installed, but click through to <a href="http://blog.smartlogicsolutions.com/wp-content/uploads/2009/05/testloginapplication.swf">see the TestLoginApplication</a> in action.</p>
<p>Future features of this component and example will include:</p>
<ul>
<li>validations on the input fields</li>
<li><a href="http://opensource.adobe.com/wiki/display/flexunit/FlexUnit">FlexUnit4</a> tests</li>
<li>transitions between the states to demo some Spark effects</li>
<li>an extended RegistrationForm class</li>
</ul>
<p>Enjoy!</p>
<div id="crp_related"><h3>Related Posts:</h3><ul><li><a href="http://blog.smartlogicsolutions.com/2008/07/16/skinning-button-flex-4-fxg/" rel="bookmark" class="crp_title">Skinning A Button in Flex 4 Using FXG</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/07/19/creating-custom-flex-4-skinnable-component/" rel="bookmark" class="crp_title">Creating Your First Custom SkinnableComponent in Flex 4</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/10/08/new-flex-4-theme-and-class-renaming/" rel="bookmark" class="crp_title">New Flex 4 Theme and Class Renaming</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/09/25/rotate-effect-and-non-embedded-fonts-in-flex-4/" rel="bookmark" class="crp_title">Rotate Effect and Non Embedded Fonts in Flex 4</a></li><li><a href="http://blog.smartlogicsolutions.com/2008/08/16/recreating-elys-flex-4-list-component-series/" rel="bookmark" class="crp_title">Recreating Ely&#8217;s Flex 4 List Component Series</a></li><li>Powered by <a href="http://ajaydsouza.com/wordpress/plugins/contextual-related-posts/">Contextual Related Posts</a></li></ul></div>]]></content:encoded>
			<wfw:commentRss>http://blog.smartlogicsolutions.com/2009/05/28/flex-4-login-form-component/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

