开发者

How can I Access Items Selected in a Component from the Main App

How can I Access Items Selected in a Component from the Main App

Hi,

I've got a component that has a listControl and a couple of RadioButtonGroups. I need to access the selected items in the main application. What's the best/simplest way to create and access the array of selected items. So, the user clicks the button to confirm the selections and then I need to access those selections in the main app. Is there a way I can use a public var to build the array? Another idea?

<mx:Tile direction="horizontal">

        <mx:Box>
            <mx:Label text="Year" fontWeight="bold"/>
            <mx:List id="myYear" >
                <mx:dataProvider>
                    <mx:Object label="09-10" data="2009_2010" />
                    <mx:Object label="08-09" data="2008_2009" />
                </mx:dataProvider>
            </mx:List>
        </mx:Box>


        <mx:Box>
            <mx:Label text="Type:" fontWeight="bold"/>
            <mx:RadioButtonGroup id="type" />
                <mx:RadioButton groupName="Type" label="Big" value="B" selected="true"/>
                <mx:RadioButton groupName="Type" label="Little" value="L"/>
        </mx:Box>


        <mx:Box >
            <mx:Label text="Level:" fontWeight="bold"/>
            <mx:RadioButtonGroup id="level" />
                <mx:RadioButton groupName="level" label="First" value="F" selected="true"/>
                <mx:RadioButton groupName="level" label="Second" value="S" />
       开发者_如何学C </mx:Box>


</mx:Tile>

<mx:Button id="Go" label="Go"  
            click="" />

Thank you.

-Laxmidi


You already have your answer. Expose the values you need to access using a public property on the component. This is written in browser, but the gist is:

[Bindable]
public var exposedValues : Array = new Array();

Then keep this value up to date with your visual components. Possibly something like this:

        <mx:RadioButtonGroup id="type" change="{this.exposedValues = type.selectedItems}" />
            <mx:RadioButton groupName="Type" label="Big" value="B" selected="true"/>
            <mx:RadioButton groupName="Type" label="Little" value="L"/>


I believe that array not need to be Bindable in this setup.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜