Using Timer to fire data binding event : Data Binding « Data Model « Flex






Using Timer to fire data binding event

Using Timer to fire data binding event
            
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" creationComplete="initHandler();">
    <mx:Script>
        
            private var _timer:Timer;
            private var _firstName:String;
            public static const FIRST_NAME_CHANGED:String = "firstNameChanged";

            private function initHandler():void
            {
                _timer = new Timer( 2000, 1 );
                _timer.addEventListener( TimerEvent.TIMER_COMPLETE, timerHandler );
            }

            private function clickHandler():void
            {

                firstName = fnInput.text;
            }
            private function timerHandler( evt:TimerEvent ):void
            {
                dispatchEvent( new Event( FIRST_NAME_CHANGED ) );
            }
    
            [Bindable(event="firstNameChanged")]
            public function get firstName():String
            {
                return _firstName;
            }
            public function set firstName( str:String ):void
            {
                 _firstName = str;
                 _timer.reset();
                 _timer.start();
            }

      
    </mx:Script>

    <mx:Panel title="User Entry.">
        <mx:HBox>
           <mx:Label text="First Name:" />
           <mx:TextInput id="fnInput" />
        </mx:HBox>
        <mx:Button label="submit" click="clickHandler();" />

        <mx:Label text="You Entered:" fontWeight="bold" />
        <mx:HBox>
            <mx:Label text="First Name:" />
            <mx:Text text="{firstName}" />
        </mx:HBox>
    </mx:Panel>
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Using binding to do an automatic copy to a targetUsing binding to do an automatic copy to a target
2.Making your own bindable variable and bind to TextInputMaking your own bindable variable and bind to TextInput
3.Binding CurlyBinding Curly
4.Bind Data To ModelBind Data To Model
5.Databinding EffectsDatabinding Effects
6.Set enabled property of Validator using data bindingSet enabled property of Validator using data binding
7.Use validator with data binding to validate either the source or destination of the data bindingUse validator with data binding to validate either the source or destination of the data binding
8.Implementing Two-Way BindingsImplementing Two-Way Bindings
9.Implementing Two-Way Bindings with Implementing Two-Way Bindings with <mx:Binding/>
10.Modify Label text through data binding
11.Applying behaviors in MXML using data bindingApplying behaviors in MXML using data binding
12.Use data binding to specify information to the value propertyUse data binding to specify information to the value property
13.data binding between Model and Form controlsdata binding between Model and Form controls
14.Include ActionScript code and E4X expressions as part of the data binding expressionsInclude ActionScript code and E4X expressions as part of the data binding expressions
15.The curly braces syntax and the tag both define a data binding at compile timeThe curly braces syntax and the <mx:Binding> tag both define a data binding at compile time
16.Using data binding with data modelsUsing data binding with data models
17.Curly braces syntax and tag both define a data binding at compile timeCurly braces syntax and <fx:Binding> tag both define a data binding at compile time
18.Make maxFontSize and minFontSize properties that you defined as variables usable as the sources for data bindings expressionsMake maxFontSize and minFontSize properties that you defined as variables usable as the sources for data bindings expressions
19.Data binding examplesUsing data binding with data modelsData binding examplesUsing data binding with data models
20.Data Binding Using Curly Braces SyntaxData Binding Using Curly Braces Syntax
21.Data Validation Through Data BindingsData Validation Through Data Bindings
22.Data Binding Through ActionScript ExpressionsData Binding Through ActionScript Expressions
23.Data Binding Using the Tag in MXML SyntaxData Binding Using the <mx:Binding> Tag in MXML Syntax
24.Use custom function during data bindingUse custom function during data binding
25.Use data binding to make your chart reflect data changes in real time.Use data binding to make your chart reflect data changes in real time.
26.Value With Data BindingValue With Data Binding
27.Value Trigger With Data Binding On ModelValue Trigger With Data Binding On Model
28.Value Trigger With Data Binding for Complex ModelValue Trigger With Data Binding for Complex Model
29.Set the enabled property by using data bindingSet the enabled property by using data binding
30.MXML bindingMXML binding
31.Binding control property to a property of another controlBinding control property  to a property of another control
32.More Uses for Curly BracesMore Uses for Curly Braces
33.Using more than one set of curly bracesUsing more than one set of curly braces
34.declare bindings outside of component tagsdeclare bindings outside of component tags
35.databinding syntax escapeddatabinding syntax escaped
36.Binding With Curly BracesBinding With Curly Braces
37.Use tag as an alternative to the curly braces syntaxUse <mx:Binding> tag as an alternative to the curly braces syntax
38.Binding a source property to more than one destination propertyBinding a source property to more than one destination property
39.Defining bidirectional bindingsDefining bidirectional bindings
40.Bind with Binding tagBind with Binding tag
41.Wrap the whole string with {} during BindingWrap the whole string with {} during Binding
42. tags in the following example are valid and equivalent to each other<fx:Binding> tags in the following example are valid and equivalent to each other
43.Converting text to upper with BindingConverting text to upper with Binding
44.Use a static constant as the source for a data-binding expressionUse a static constant as the source for a data-binding expression
45.Create a String variable for bindingCreate a String variable for binding
46.Multiple Destinations bindingMultiple Destinations binding
47.Using multiple tagsUsing multiple <mx:Binding/> tags
48.Multilevel BindingsMultilevel Bindings
49.Simple Binding TestSimple Binding Test
50.Using Binding TagUsing Binding Tag
51.Create a Bidirectional BindingCreate a Bidirectional Binding
52.Create a Bidirectional Binding with Binding tagCreate a Bidirectional Binding with Binding tag
53.Bind to a Property with Binding tag
54.Property BindingProperty Binding
55.Bind to a PropertyBind to a Property
56.Using functions that take bindable properties as argumentsUsing functions that take bindable properties as arguments
57.Use Bindable Property Chains
58.Bind to a FunctionBind to a Function
59.Create Customized Bindable PropertiesCreate Customized Bindable Properties
60.A single bindable property inside curly bracesA single bindable property inside curly braces
61.Concatenate and manipulate the information inside the curly bracesConcatenate and manipulate the information inside the curly braces
62.both source and destination properties must resolve to a bindable property or property chain at compile timeboth source and destination properties must resolve to a bindable property or property chain at compile time
63.When bindable property changes, the function executes, and the result is written to the destination propertyWhen bindable property changes, the function executes, and the result is written to the destination property