动作脚本3-选择了哪个Accordion孩子



有没有办法通过Accordion headerRenderer发现选择了哪个子项?

我使用的是flexrib中的CanvasButtonAccordionHeader,我想只在selectedChild的标头中显示一个组件。

谢谢你的任何有用的提示。

您可以使用定义内联headerRenderer并使用outerDocument属性。这是一个例子:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:ns="http://code.google.com/p/flexlib/">
    <fx:Declarations>
        <!-- Place non-visual elements (e.g., services, value objects) here -->
    </fx:Declarations>
    <mx:Accordion id="acc" width="400" height="400" headerHeight="40">
        <mx:headerRenderer>
            <fx:Component>
                <ns:CanvasButtonAccordionHeader label="{'selected ' +outerDocument.acc.selectedChild.label}">   
                </ns:CanvasButtonAccordionHeader>
            </fx:Component>
        </mx:headerRenderer>
        <mx:Canvas   label="Personal"  toolTip="Child number one">
            <mx:Label text="Contents of Child 1" />
        </mx:Canvas>
        <mx:Canvas label="Accounts" toolTip="Child number two">
            <mx:Label text="Contents of Child 2" />
        </mx:Canvas>
        <mx:Canvas label="Help" toolTip="Child number three">
            <mx:Label text="Contents of Child 3" />
        </mx:Canvas>
    </mx:Accordion>
</s:Application>

Davide

最新更新