David Harris's Technology Blog

ColdFusion, Flex, and other stuff...   (and 323,446 hours, 21 mins in to my plan for global domination)

Search:

Calendar:

Sun Mon Tue Wed Thu Fri Sat
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Subscribe:

Enter your email address to subscribe to this blog.

Archives By Subject:

Tags:

adobe air ajax cfug coldfusion flash flex frameworks free software fxug general jpgmetadatareader mac off topic opensource papervision spry

Recent Entries:

Top Posts:

Recent Comments:

Top Commenters:

My Links:

RSS:


Binding of properties between sub components

On the NZ Flex UG list, (another) David posted this question.

In the process of testing what he outlined, I created a simple example, which I have posted here.

The point of this example is to show how you can declare "public" variables in a component, and then access those variables as properties form the component that uses it...

The example consists of 2 files:

FormExample.mxml (Application File)

Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" >
   
   <mx:Panel>
      <!-- call in the MyForm component -->
      <local:MyForm
         id="myForm"
         title="My Form"
         xmlns:local="*"
      />

      
      <!--
         a button with the "enabled" property bound to the "formValid" property of the myForm component above
      -->

      <mx:Button
         id="myButton"
         label="My Button: enabled is '{myButton.enabled.toString()}'"
         enabled="{myForm.formValid}"
      />

      
   </mx:Panel>
   
</mx:Application>

MyForm.mxml (in the root folder of the project)

Code:

<?xml version="1.0" encoding="utf-8"?>
<mx:Panel xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical">

   <mx:Script>
      <![CDATA[
         /*
            Create property and expose it by declaring it as "public",
            and let the compiler know to make if bindable using the [Bindable] meta tag
         */

         [Bindable] public var formValid:Boolean = false;
      ]]>
   </mx:Script>
   <!-- Something to let us know if the 'form' is currently Valid or Invalid -->
   <mx:Text text="Form is Currently {formValid == true ? 'Valid' : 'Invalid'}" />
   
   <!-- simple button to toggle the formValid status -->
   <mx:Button label="Toggle Form Valid" click="formValid = !formValid;" />

</mx:Panel>

Result:

My Flex Playing requires Adobe Flash Player 9. Get Adobe Flash..

Feel free to ask questions!

PS: There can NEVER be enough Davids!

Comments