<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-6260601054290342602</id><updated>2012-02-16T06:18:28.096-08:00</updated><title type='text'>The Adventures of Flexy Frederick</title><subtitle type='html'>programming, music, politics, and romance.</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://flexyfrederick.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6260601054290342602/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://flexyfrederick.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Flexy Frederick</name><uri>http://www.blogger.com/profile/13776515362367643245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://2.bp.blogspot.com/_8kOuMrOV1R4/SZlcXbet_oI/AAAAAAAAAAk/_GR5gjsvxhk/S220/profile+after+exquisite.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-6260601054290342602.post-5622032413569374012</id><published>2009-03-04T08:56:00.000-08:00</published><updated>2009-03-04T12:14:18.489-08:00</updated><title type='text'>Getting Started with OpenFlux 1: the basics</title><content type='html'>&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://4.bp.blogspot.com/_8kOuMrOV1R4/Sa7cFWt6cpI/AAAAAAAAABY/fNbhu3xE_qk/s1600-h/Basic+OpenFlux+folders.png"&gt;&lt;/a&gt;&lt;p&gt;In this example I’ll show you how to create a useful component for social networking websites: a Link to a user’s page with the user’s photo, name or both. Then in part 2 I’ll show you how to organize them into a list and connect them with Cairngorm. The OpenFlux framework is somewhat different to vanilla Flex - forget everything you already know for now - later things will start to reconnect. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;These tutorials requires active participation, try writing the code as you read the samples. I recommend you type everything in as FlexBuilder will autocomplete a lot of imports and assign namespaces. Even if you just cut and paste a bit, it’s good practice to make the individual file. The really fascinating thing about OpenFlux is seeing how all the different classes work together - the architecture. After the next release of OpenFlux I’ll post a video version too. &lt;/p&gt;&lt;p&gt;These are 'my' methods of using OpenFlux not 'the' method and certainly not the only one. In particular it is common to use public variables on Component, rather than a VO, as the data model. I prefer this approach as it works smoothly with Cairngorm, as we shall see in part 2... but I'm getting ahead of myself.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The first step is to identify how the component will be used in an application, it’s ’use cases’. There are two kinds of use case for a visual component. They display dynamic information and respond to certain user gestures (i.e. mouse or keyboard events). So we ask ourselves:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;li&gt;what does it show?&lt;/li&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;li&gt;what does it do?&lt;/li&gt;&lt;/ol&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Then we write a Value Object (VO) that provides the information necessary for the component to do and show what it will. A VO is simply an actionscript class that has only public properties or getter/setters. A VO will act as Data Model for our component. Link shows a photo and the user’s name. Therefore our component’s VO requires a string for the name and another string for the URL where the image will be found:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#6699cc;"&gt;&lt;b&gt;var&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; photoUrl:String;&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#6699cc;"&gt;&lt;b&gt;var&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; name:String;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;We want to show the user’s page when the Link is clicked, so the component also needs to know the user’s ID: &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#6699cc;"&gt;&lt;b&gt;var &lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;userID:uint;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;So we create a class called LinkVO that has nothing but these 3 public variables. Eventually this class will hold information received from our server, mapped with remote class metadata to a java equivalent. &lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Next we need to make a few more files. First the component itself, Link, which holds all the other parts together. Then we will make a two views; one with the user’s name the other with their photo. Being able to readily change the apparence of components is a major strength of OpenFlux, and is far easier to use than messing around with Flex borderSkin assignments etc. etc. Finally we’ll  write a simple controller that will subscribe responses to mouse clicks on the view.&lt;/p&gt;&lt;a onblur="try {parent.deselectBloggerImageGracefully();} catch(e) {}" href="http://1.bp.blogspot.com/_8kOuMrOV1R4/Sa7Zl2CNq0I/AAAAAAAAABI/1ikzO2rPvQg/s1600-h/Components+part+1.png"&gt;&lt;img style="display:block; margin:0px auto 10px; text-align:center;cursor:pointer; cursor:hand;width: 400px; height: 250px;" src="http://1.bp.blogspot.com/_8kOuMrOV1R4/Sa7Zl2CNq0I/AAAAAAAAABI/1ikzO2rPvQg/s400/Components+part+1.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5309420254899579714" /&gt;&lt;/a&gt;&lt;br /&gt;&lt;table cellspacing="0" cellpadding="0" width="500" border="0"&gt;&lt;tbody&gt;&lt;/tbody&gt;&lt;tbody&gt;&lt;tr&gt;&lt;td&gt;&lt;em&gt;role &lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;name &lt;/em&gt;&lt;/td&gt;&lt;td&gt;&lt;em&gt;extends &lt;/em&gt;&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;component&lt;/td&gt;&lt;td&gt;Link.as &lt;/td&gt;&lt;td&gt;ListItem &lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;view&lt;/td&gt;&lt;td&gt;TextLinkView.mxml&lt;/td&gt;&lt;td&gt;FluxView&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;view&lt;/td&gt;&lt;td&gt;ImageLinkView.mxml&lt;/td&gt;&lt;td&gt;FluxView&lt;/td&gt;&lt;/tr&gt;&lt;tr&gt;&lt;td&gt;controller&lt;/td&gt;&lt;td&gt;LinkController.as&lt;/td&gt;&lt;td&gt;FluxController&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;The view is displays information. The controller responds to user gestures. The component stores the VO and sets the default view and controller. I recommend the pictured folder structure. In the downloadable files these are at.newbe.model etc. &lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 238); "&gt;&lt;img src="http://4.bp.blogspot.com/_8kOuMrOV1R4/Sa7cFWt6cpI/AAAAAAAAABY/fNbhu3xE_qk/s320/Basic+OpenFlux+folders.png" border="0" alt="" id="BLOGGER_PHOTO_ID_5309422995272004242" style="display: block; margin-top: 0px; margin-right: auto; margin-bottom: 10px; margin-left: auto; text-align: center; cursor: pointer; width: 218px; height: 215px; " /&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style=" ;font-size:24px;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;Link&lt;/span&gt; &lt;em&gt;- component&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;First override the getter and setter functions for data from the parent class (ListItem). I’ll talk more about data when we put our Link in List. We’ll runtime type check that a LinkVO has been assigned to this property:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;private &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#6699cc;"&gt;&lt;b&gt;var&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; _linkVO:LinkVO; &lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;override &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#339966;"&gt;&lt;b&gt;function &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;get&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; data():Object { &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; _linkVO; }&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;override &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#339966;"&gt;&lt;b&gt;function &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;set&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; data(value:Object):&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; {&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; (value &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;is&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; LinkVO) _linkVO = value &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;as&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; LinkVO;&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;ListItem implements IFactory with its newInstance():* method. We must override this so it returns a Link, rather than a ListItem. Implementing IFactory allows a component be a List’s item renderer. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div dir="ltr"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;override &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#339966;"&gt;&lt;b&gt;function&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; newInstance():* {&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#6699cc;"&gt;&lt;b&gt;var&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; instance:Link = &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; Link();&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;return&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; instance;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div dir="ltr"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;}&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Finally we’ll set the default view and controller. We do this by overriding the protected createChildren() method. If the view or controller are undefined, set values as new instances of the defaults. Mark the class as [Bindable] And that’s it! Check the class you have written is the same as the downloaded file. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;override &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;protected &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#339966;"&gt;&lt;b&gt;function&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; createChildren():&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; {&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;(!controller) controller = &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; LinkController();&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;if&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;(!view) view = &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;new&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; TextLinkView();&lt;br /&gt;&lt;span class="Apple-style-span"   style="  ;font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;super&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;.createChildren();&lt;br /&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:6;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;TextLinkView&lt;/span&gt; &lt;em&gt;- view showing user’s name&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Now we’ll make a very simple view that will display the user’s name. Open tags for the property +content, within them place a label with text bound to {component.data.name}:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;flux:content&amp;gt;&lt;br /&gt;&lt;span class="Apple-style-span"   style="color: rgb(0, 0, 0);   font-family:Georgia;font-size:16px;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;mx:Label&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; text="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;component.data.name&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;"&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;br /&gt;&amp;lt;/flux:content&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;All visual components that will be displayed by the view are placed within the FluxView’s content variable. Anything else, like degrafa fills/strokes and states go outside. Note that you can access the component with the eponymous variable, and thus we bind the view directly to the VO. I love &amp;lt;10 line classes! &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:6;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;PhotoLinkView&lt;/span&gt; &lt;em&gt;- view showing user’s profile photo&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Next a more interesting view that shows the user’s profile photo. There are lots of ways to do this, but this is by far the best I have found. We’ll display the photo using a Degrapha image fill, with an image loaded from the photoUrl property of LinkVO: &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;paint:BitmapFill&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; id="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;photo&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;"&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; source="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;component.data.photoUrl&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" smooth="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;true&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;"&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; repeatX="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;BitmapFill.STRETCH&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" repeatY="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;BitmapFill.STRETCH&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;One advantage of this method over the default Flex Image component is advanced anti-aliasing, set by smooth="true". This fill will scale to the size of the shape it’s applied to. Next we’ll make a solid-stroke outline for the photo, and a rectangle for fill&lt;br /&gt;and stroke to be applied to:&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;degrafa:SolidStroke&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; id="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;edge&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;"&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; color="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;#FF9900&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" weight="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;2&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;"&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; caps="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;round&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" joints="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;round&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" pixelHinting="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;true&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt; &lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;degrafa:GeometryComposition&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; graphicsTarget="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;[image]&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;"&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;degrafa:RoundedRectangle&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; width="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;width&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" height="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;height&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" fill="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;photo&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" stroke="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;edge&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" cornerRadius="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;2.5&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;/degrafa:GeometryComposition&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;The graphicsTarget is a component called image within content. This will simply be another FluxView. Think of FluxView used this way as similar to how you might use Canvas in Flex Component development: &lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;flux:content&amp;gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;flux:FluxView&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; id="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;image&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" width="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;width ? width : 54&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" height="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;height ? height : 54&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&amp;lt;/flux:content&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;The number 54 in the width and height setting are the default width and height setting for this component. I’ve tried several other ways of setting defult height, including measure() and setting in the parent tag of the mxml document. It seems that currently there are bugs if you have only degrafa shapes within content. This seems a neat enough solution, thoughts on performance anyone?&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt; &lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt; &lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:6;"&gt;&lt;span style="font-size:180%;"&gt;&lt;span class="Apple-style-span" style="font-weight: bold;"&gt;LinkController &lt;/span&gt;&lt;em&gt;- controller&lt;/em&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;This  controller is very simple, in part because of some of OpenFlux’s fantastic custom metadata tags. Create a private variable with the same and type as our component, Link. Now add the [ModelAlias] tag before it, and this variable will represent a typed reference to the component at runtime. &lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;[ModelAlias] &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;private &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#6699cc;"&gt;&lt;b&gt;var&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; link:Link;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;/span&gt;This can save a lot of runtime type checking in more sophisticated controller. Now add the following metadata at the top of the class:&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;[ViewHandler(event=&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;&lt;b&gt;"mouseUp"&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;, handler=&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;&lt;b&gt;"mouseUpHandler"&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;)]&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;public &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#9900cc;"&gt;&lt;b&gt;class&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; LinkController &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;extends&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; FluxController &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;/span&gt;The ViewHandler tag helps you listen to mouse and keyboard events from the view, and name a handler to respond to them. In this case we’re listening for mouseup with a handler called mouseUpHandler. Let’s define that function:&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;metadata &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#339966;"&gt;&lt;b&gt;function&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; mouseUpHandler(event:MouseEvent):&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0033ff;"&gt;&lt;b&gt;void&lt;/b&gt;&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; {&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#cc6666;"&gt;&lt;b&gt;trace( &lt;/b&gt;&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;&lt;b&gt;"please show me the user’s page" );&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;} &lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;/span&gt;Note that we define a metadata function, rather than private. This allows the metadata processor to wire things together properly. Next episode we’ll dispatch a Cairngorm Event call from this function... bet you can’t wait! Using the metadata is crucial to getting the most out of OpenFlux, this is a taste but much more is possible. I explain fully how to use these and the other metadata tags in &lt;a href="http://flexyfrederick.blogspot.com/2009/02/joy-of-openflux-metadata.html"&gt;this blog post. &lt;/a&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;div&gt;&lt;/div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style="font-size:24px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span"  style="font-size:24px;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:6;"&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span style="font-size:180%;"&gt;Testing our new component&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Open up Main.mxml and create a LinkVO with some dummy information. Then make a PhotoLinkView. Then create a 2 Links in an HBox, and bind it’s data property to the LinkVO:&lt;/p&gt;&lt;blockquote&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;vo:LinkVO&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; id="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;user1&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" photoUrl="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;assets/images/01.jpg&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" name="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;Flexy Frederick&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" userID="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;1&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;br /&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;views:PhotoLinkView&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; id="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;photo&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" visible="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;false&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;Then create a 2 Links in a VBox, and bind their data properties to the LinkVO. Set the PhotoLinkView as the view for one of them:&lt;/div&gt;&lt;blockquote&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;mx:VBox&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;view:Link&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; data="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;user1&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" view="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;photo&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;view:Link&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt; data="&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;{&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;user1&lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#990000;"&gt;}&lt;/span&gt;&lt;span style=" ;font-family:Courier New;font-size:10pt;"&gt;" &lt;/span&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;/&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="  ;font-family:Courier New;font-size:10pt;color:#0000ff;"&gt;&amp;lt;/mx:VBox&amp;gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;div&gt;Compile as see the user’s photo followed by their name. Click on either of them and the controller will trace. Congratulations you have now mastered the basics architecture of a single OpenFlux component. In part two we’ll use Link as an itemRenderer for the List component, an advanced container supporting dynamic layouts. We’ll also hook things up to Cairngorm, a powerful Adobe supported MVC application archetitecure. &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6260601054290342602-5622032413569374012?l=flexyfrederick.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://flexyfrederick.blogspot.com/feeds/5622032413569374012/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://flexyfrederick.blogspot.com/2009/03/getting-started-with-openflux-1-basics.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6260601054290342602/posts/default/5622032413569374012'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6260601054290342602/posts/default/5622032413569374012'/><link rel='alternate' type='text/html' href='http://flexyfrederick.blogspot.com/2009/03/getting-started-with-openflux-1-basics.html' title='Getting Started with OpenFlux 1: the basics'/><author><name>Flexy Frederick</name><uri>http://www.blogger.com/profile/13776515362367643245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://2.bp.blogspot.com/_8kOuMrOV1R4/SZlcXbet_oI/AAAAAAAAAAk/_GR5gjsvxhk/S220/profile+after+exquisite.jpg'/></author><media:thumbnail xmlns:media='http://search.yahoo.com/mrss/' url='http://1.bp.blogspot.com/_8kOuMrOV1R4/Sa7Zl2CNq0I/AAAAAAAAABI/1ikzO2rPvQg/s72-c/Components+part+1.png' height='72' width='72'/><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-6260601054290342602.post-8661752543683537047</id><published>2009-02-19T19:12:00.000-08:00</published><updated>2009-02-19T11:14:01.234-08:00</updated><title type='text'>The Joy of OpenFlux Metadata</title><content type='html'>&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;/blockquote&gt;Custom Metadata a real strength of the OpenFlux framework, abbreviating a lot of very dull, repetitive and fiddly tasks. Here is as overview of what's currently possible, organized by what I've found to be common use cases.  &lt;/div&gt;&lt;div&gt;Metadata tagged before a variable work equally before an accessor and visa versa. All these metadata are to be used in the controller, apart from [StyleBinding] which can be used in the model, view or the controller. Where I've quoted mxml tags I've used { and } instead of less than/greater than - this is due to I think a bug with blogger, any suggestions about this, or any spelling mistakes please comment. I'm dyslexic, (hence the color!) and value clarity of communication very highly, so if anything doesn't make perfect sense please point it out and I'll try to clarify. &lt;/div&gt;&lt;div&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;&lt;strong&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Referencing the Component with &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[ModelAlias]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;/p&gt;&lt;p&gt;Simply add the &lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); "&gt;[ModelAlias]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0); "&gt; &lt;/span&gt;tag before a variable declaration. Now you can use this variable to reference to the component anywhere in your controller. &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); "&gt;[ModelAlias]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0); "&gt; &lt;/span&gt;public var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;typedComponent&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;CustomComponent&lt;/span&gt;;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;If the component can be typed as &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;CustomComponent &lt;/span&gt;at runtime, then the variable &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;typedComponent &lt;/span&gt;will reference the component, otherwise it will be null.&lt;br /&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Note: &lt;/span&gt;although the &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;FluxController&lt;/span&gt;'s &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;component&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;IFluxComponent &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;variable also &lt;/span&gt;references the component, you will need to do a lot of  &lt;span class="Apple-style-span" style="font-style: italic;"&gt;tedious &lt;/span&gt;type casting to make use of it e.g. &lt;/p&gt; &lt;blockquote&gt; &lt;p&gt;var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;c&lt;/span&gt;:&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;CustomComponent &lt;/span&gt;&lt;/span&gt;= &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;component &lt;/span&gt;as &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;CustomComponent&lt;/span&gt;&lt;/span&gt;;&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;c.customProperty&lt;/span&gt; = &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;value&lt;/span&gt;; &lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;Fortunately &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ModelAlias]&lt;/span&gt;&lt;/span&gt; provides a very neat shortcut, use it every time.&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Referencing children of the view with &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); font-weight: bold;"&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0); font-weight: normal; "&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Suppose that your view contains a child element that you'd like to reference in the controller for some reason:&lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;{ flux:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;FluxButton&lt;/span&gt; id="&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;submit&lt;/span&gt;" /}&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;p&gt;Simply add the&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); "&gt; [ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); "&gt; &lt;/span&gt;tag before a variable with the same name and type in the controller. &lt;/p&gt;&lt;blockquote&gt;&lt;p&gt;&lt;span class="Apple-style-span"&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255); "&gt;[ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;private var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;_submit&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;FluxButton&lt;/span&gt;&lt;br /&gt;public fucntion get &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;submit&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;()&lt;/span&gt;&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;FluxButton &lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;{ &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;return &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;_submit&lt;/span&gt;; }&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;public function set &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;submit(&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;value&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 0, 0);"&gt;:&lt;/span&gt;FluxButton&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;)&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(51, 51, 51);"&gt;void &lt;/span&gt;{&lt;br /&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;        &lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;_submit &lt;/span&gt;= value;&lt;br /&gt;}&lt;/span&gt;&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt; &lt;p&gt;If the name and type match, &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;submit &lt;/span&gt;will reference the button, otherwise null.&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;Note: &lt;/span&gt;you can also reference children of the view by typing  &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;component.view&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;IFluxView&lt;/span&gt; and accessing it's custom properties. This can get &lt;span class="Apple-style-span" style="font-style: italic;"&gt;very &lt;/span&gt;&lt;span class="Apple-style-span" style="font-style: italic;"&gt;messy so don't bother -&lt;/span&gt; &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewContract] &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;is a fantastic shortcut. &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;blockquote&gt; &lt;p&gt; &lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Adding event listeners to the view with &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[ViewHandler]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;Your view may dispatch mouse of keyboard events that need to be handled.  There are two steps. &lt;/p&gt; &lt;ol&gt; &lt;li&gt;Add a &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewHandler]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;tag at the top of the controller class specifying the  names of the event you want to listen for, and the function that will handle it.   &lt;/li&gt;&lt;li&gt;Define a metadata function with a matching name (metadata functions are  written in exactly the same way as public/private/protected functions).  &lt;/li&gt;&lt;/ol&gt; &lt;blockquote&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewHandler (event="click", handler="clickHandler")]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;public class &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;CustomController &lt;/span&gt;extends &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;FluxController &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;metadata &lt;/span&gt;&lt;/span&gt;function &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;clickHandler&lt;/span&gt;(event:MouseEvent):void { trace("clicked the  view"); } &lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt;now when the view is clicked, mouseUpHandler() will fire, easy huh?  Especially useful for simple controls like buttons. See &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;ButtonController &lt;/span&gt;for an  example.&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style="font-weight: bold; "&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;&lt;br /&gt;Adding event listeners to children of the view with&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[EventHandler]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt; and &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt; &lt;p&gt;Whilst&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewHandler]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;works fine for events from simple controls like buttons,  it is not suitable for something like a button bar where you need to know which  particular subcomponent of the view dispatched the event.&lt;/p&gt;&lt;p&gt;&lt;/p&gt;&lt;blockquote&gt;{ flux:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;FluxButton&lt;/span&gt; id="&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;button1&lt;/span&gt;" /}&lt;br /&gt;{ flux:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0); "&gt;FluxButton&lt;/span&gt; id="&lt;span class="Apple-style-span" style="color: rgb(153, 51, 153); "&gt;button2&lt;/span&gt;" /}&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt;&lt;ol&gt;&lt;li&gt;Define a variable with the same name and type as the  subcomponent you are interested in.&lt;br /&gt;&lt;/li&gt;&lt;li&gt;Add a&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;tag, now the variable references the subcomponent. &lt;/li&gt;&lt;li&gt;Add an &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[EventHandler]&lt;/span&gt;&lt;/span&gt; tag with the name of the event to listen  for and the name of the handler.  &lt;/li&gt;&lt;li&gt;Define a handler metadata function with the same name&lt;/li&gt;&lt;/ol&gt; &lt;blockquote&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[EventHandler (event="click", handler="button1ClickHandler")] &lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt; &lt;/span&gt;public var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;button1&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;FluxButton &lt;/span&gt;; &lt;/p&gt;&lt;/blockquote&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[EventHandler(event="click", handler="button2ClickHandler")]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[ViewContract]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt; &lt;/span&gt;public var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;button2&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;FluxButton &lt;/span&gt;; &lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;metadata &lt;/span&gt;&lt;/span&gt;function &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;button1ClickHandler&lt;/span&gt;(event:MouseEvent):void { trace("clicked  button 1"); }&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;metadata &lt;/span&gt;&lt;/span&gt;function &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;button2ClickHandler&lt;/span&gt;(event:MouseEvent):void { trace("clicked  button 2"); }&lt;/p&gt;&lt;/blockquote&gt;&lt;p&gt;In general tagging a variable with &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;[EventHandler]&lt;/span&gt; adds the named handler function as a listener to the named event dispatched by the variable.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Adding event listeners to the component with  &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[EventHandler]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;When &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[EventHandler]&lt;/span&gt;&lt;/span&gt; appears at the top of a class it behaves somewhat  differently to when it is appears before a variable. At the top of a  class&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[EventHandler]&lt;/span&gt;&lt;/span&gt; adds an event listener for an event dispatched from the  component, for example when a property changes. &lt;/p&gt; &lt;blockquote dir="ltr" style="MARGIN-RIGHT: 0px"&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[EventHandler(event="propertyChange", handler="propertyChangeHandler")]&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;public class &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;CustomController &lt;/span&gt;extends &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;FluxController &lt;/span&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;metadata &lt;/span&gt;&lt;/span&gt;function &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;propertyChangeHandler&lt;/span&gt;(event:PropertyChangeEvent):void {  trace("component property changed"); }&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;/blockquote&gt; &lt;p&gt; &lt;/p&gt; &lt;p&gt;&lt;strong&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;Using &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt;[StyleBinding]&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span"  style="font-size:large;"&gt; to synchronize styles across the component, view  and controller &lt;/span&gt;&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[StyleBinding] &lt;/span&gt;&lt;/span&gt;tags can appear before any variable in the  component, the view or the controller. If a style that has the same name and  type as the &lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[StyleBinding]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;tagged variable can be resolved for the component,  then the variable will be bound to that style at runtime.&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[StyleBinding]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;public  var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;selectable&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;Boolean&lt;/span&gt;;&lt;br /&gt;&lt;span class="Apple-style-span" style=""&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[StyleBinding]&lt;/span&gt;&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(51, 204, 0);"&gt; &lt;/span&gt;public var &lt;span class="Apple-style-span" style="color: rgb(153, 51, 153);"&gt;layout&lt;/span&gt;:&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;ILayout&lt;/span&gt;;&lt;/blockquote&gt;&lt;p&gt;&lt;/p&gt; &lt;p&gt;This way you can specify all the styles required by all three classes within the CSS style declaration for the component, try it out - works like magic! If you want to style the component inline you need to add the vanilla Flex &lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[Style]&lt;/span&gt;&lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt; &lt;/span&gt;tag at the top of the component class,  a good example can be found in &lt;span class="Apple-style-span" style="color: rgb(0, 153, 0);"&gt;ButtonController&lt;/span&gt;. &lt;br /&gt;Also note that &lt;span class="Apple-style-span" style="color: rgb(51, 51, 255);"&gt;[StyleBinding]&lt;/span&gt; allows you to treat style values in the same way as normal bound variables. This is far simpler than esoteric flex methods like getStyle() and overriding styleChanged(). &lt;/p&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/6260601054290342602-8661752543683537047?l=flexyfrederick.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://flexyfrederick.blogspot.com/feeds/8661752543683537047/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://flexyfrederick.blogspot.com/2009/02/joy-of-openflux-metadata.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/6260601054290342602/posts/default/8661752543683537047'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/6260601054290342602/posts/default/8661752543683537047'/><link rel='alternate' type='text/html' href='http://flexyfrederick.blogspot.com/2009/02/joy-of-openflux-metadata.html' title='The Joy of OpenFlux Metadata'/><author><name>Flexy Frederick</name><uri>http://www.blogger.com/profile/13776515362367643245</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='25' height='32' src='http://2.bp.blogspot.com/_8kOuMrOV1R4/SZlcXbet_oI/AAAAAAAAAAk/_GR5gjsvxhk/S220/profile+after+exquisite.jpg'/></author><thr:total>1</thr:total></entry></feed>
