Bind to a Generic Object : Object « Development « Flex






Bind to a Generic Object

Bind to a Generic Object
           
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="http://www.adobe.com/2006/mxml">
    <mx:Script>
        
            import mx.utils.ObjectProxy;
            
            private var obj:Object = {name:'Name',album:'Song',genre:'Rock'};
            
            [Bindable]
            private var proxy:ObjectProxy = new ObjectProxy( obj );
            
            private function handleClick():void
            {
                proxy.name = nameField.text;
                proxy.album = albumField.text;
                proxy.genre = genreField.text;
            }
      
    </mx:Script>
    
    <mx:Form borderStyle="solid">
        <mx:FormItem label="Name:">
            <mx:TextInput id="nameField" />
        </mx:FormItem>
        <mx:FormItem label="Album:">
            <mx:TextInput id="albumField" />
        </mx:FormItem>
        <mx:FormItem label="Genre:">
            <mx:TextInput id="genreField" />
        </mx:FormItem>
        <mx:FormItem label="Submit Changes">
            <mx:Button label="ok" click="handleClick();" />
        </mx:FormItem>
    </mx:Form>
    
    <mx:Form borderStyle="solid">
        <mx:FormItem label="Name:">
            <s:RichText text="{proxy.name}" />
        </mx:FormItem>
        <mx:FormItem label="Album:">
            <s:RichText text="{proxy.album}" />
        </mx:FormItem>
        <mx:FormItem label="Genre:">
            <s:RichText text="{proxy.genre}" />
        </mx:FormItem>
    </mx:Form>
    
</mx:Application>

   
    
    
    
    
    
    
    
    
    
    
  








Related examples in the same category

1.Create an Object, adds properties, and inspect its propertiesCreate an Object, adds properties, and inspect its properties
2.Create a generic Object, adds properties to that objectCreate a generic Object, adds properties to that object
3.Define objects using properties directly in the Object tagsDefine objects using properties directly in the Object tags
4.Using source and property properties to specify an objectUsing source and property properties to specify an object