Home

Advertisement

Customize

Navigating a ViewStack using a ComboBox

« previous entry | next entry »
Jun. 11th, 2008 | 04:00 pm

This is just some example code that shows how to navigate the layers of a viewstack using a combobox or a repeater-ed radio button.

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
        <mx:Panel layout="absolute" title="ViewStack controlled by ComboBox" width="418" horizontalCenter="0" height="298" verticalCenter="0">
                <mx:ComboBox x="104" y="10"
                    dataProvider="{viewstack1.getChildren()}"
                    change="{viewstack1.selectedChild=event.currentTarget.selectedItem}"></mx:ComboBox>
                <mx:ViewStack x="26" y="42" id="viewstack1" width="200" height="200">
                    <mx:Canvas id="View1" label="View 1" width="100%" height="100%"
                        borderStyle="solid" backgroundColor="#FF0000">
                        <mx:CheckBox x="10" y="10" label="view1"/>
                    </mx:Canvas>
                    <mx:Canvas id="test1" label="test1" width="100%" height="100%"
                        borderStyle="solid" backgroundColor="#FFFF00">
                        <mx:CheckBox x="72.5" y="10" label="view2"/>
                    </mx:Canvas>
                    <mx:Canvas id="test2" label="test2" width="100%" height="100%"
                        backgroundColor="#0FFF00" borderStyle="solid">
                        <mx:CheckBox x="145" y="10" label="view3"/>
                    </mx:Canvas>
                    <mx:Canvas id="thisbutton1" label="thisbutton1" width="100%" height="100%"
                        borderStyle="solid" backgroundColor="#0000FF">
                        <mx:CheckBox x="72.5" y="74" label="view4"/>
                    </mx:Canvas>
                </mx:ViewStack>
                <mx:Panel layout="vertical" x="234" y="42">
                    <mx:Repeater id="productsRepeater"
                        dataProvider="{viewstack1.getChildren()}">
                        <mx:RadioButton
                            id="buttonsArray"
                            label="{productsRepeater.currentItem.label}"    
                            data="{productsRepeater.currentItem}"
                            change="{viewstack1.selectedChild=event.currentTarget.data}"

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

Link | Leave a comment | Add to Memories | Tell a Friend

Comments {0}