使Accordion控件的头部不可单击.
Accordion控件的mouseEnabled属性.
示例1: 示例2: 代码:
示例1代码:
comps/MyAccHeader.as:
示例2代码:
示例1: 示例2: 代码:
示例1代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
private function prevChild():void {
accordion.selectedIndex--;
}
private function nextChild():void {
accordion.selectedIndex++;
}
]]>
</mx:Script>
<mx:Accordion id="accordion"
headerRenderer="comps.MyAccHeader"
width="100%" height="100%">
<mx:VBox id="v1" label="One" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="One" />
</mx:VBox>
<mx:ControlBar horizontalAlign="right" width="100%">
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v2" label="Two" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Two" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v3" label="Three" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Three" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v4" label="Four" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Four" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v5" label="Five" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Five" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
</mx:ControlBar>
</mx:VBox>
</mx:Accordion>
</mx:Application>
<!-- http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
private function prevChild():void {
accordion.selectedIndex--;
}
private function nextChild():void {
accordion.selectedIndex++;
}
]]>
</mx:Script>
<mx:Accordion id="accordion"
headerRenderer="comps.MyAccHeader"
width="100%" height="100%">
<mx:VBox id="v1" label="One" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="One" />
</mx:VBox>
<mx:ControlBar horizontalAlign="right" width="100%">
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v2" label="Two" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Two" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v3" label="Three" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Three" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v4" label="Four" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Four" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
<mx:Button label="next" click="nextChild();" />
</mx:ControlBar>
</mx:VBox>
<mx:VBox id="v5" label="Five" width="100%" height="100%">
<mx:VBox width="100%" height="100%">
<mx:Label text="Five" />
</mx:VBox>
<mx:ControlBar width="100%">
<mx:Button label="prev" click="prevChild();" />
<mx:Spacer width="100%" />
</mx:ControlBar>
</mx:VBox>
</mx:Accordion>
</mx:Application>
comps/MyAccHeader.as:
/**
* http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/
*/
package comps {
import mx.containers.accordionClasses.AccordionHeader;
public class MyAccHeader extends AccordionHeader {
public function MyAccHeader() {
super();
mouseEnabled = false;
}
}
}
* http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/
*/
package comps {
import mx.containers.accordionClasses.AccordionHeader;
public class MyAccHeader extends AccordionHeader {
public function MyAccHeader() {
super();
mouseEnabled = false;
}
}
}
示例2代码:
<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
private function prevChild():void {
accordion.selectedIndex--;
}
private function nextChild():void {
accordion.selectedIndex++;
}
]]>
</mx:Script>
<mx:Accordion id="accordion"
headerRenderer="comps.MyAccHeader"
width="100%"
height="100%">
<mx:VBox id="v1"
label="One"
width="100%"
height="100%">
<mx:Label text="One" />
</mx:VBox>
<mx:VBox id="v2"
label="Two"
width="100%"
height="100%">
<mx:Label text="Two" />
</mx:VBox>
<mx:VBox id="v3"
label="Three"
enabled="false"
width="100%"
height="100%">
<mx:Label text="Three" />
</mx:VBox>
<mx:VBox id="v4"
label="Four"
enabled="false"
width="100%"
height="100%">
<mx:Label text="Four" />
</mx:VBox>
<mx:VBox id="v5"
label="Five"
width="100%"
height="100%">
<mx:Label text="Five" />
</mx:VBox>
</mx:Accordion>
</mx:Application>
comps/MyAccHeader.as :<!-- http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">
<mx:Script>
<![CDATA[
private function prevChild():void {
accordion.selectedIndex--;
}
private function nextChild():void {
accordion.selectedIndex++;
}
]]>
</mx:Script>
<mx:Accordion id="accordion"
headerRenderer="comps.MyAccHeader"
width="100%"
height="100%">
<mx:VBox id="v1"
label="One"
width="100%"
height="100%">
<mx:Label text="One" />
</mx:VBox>
<mx:VBox id="v2"
label="Two"
width="100%"
height="100%">
<mx:Label text="Two" />
</mx:VBox>
<mx:VBox id="v3"
label="Three"
enabled="false"
width="100%"
height="100%">
<mx:Label text="Three" />
</mx:VBox>
<mx:VBox id="v4"
label="Four"
enabled="false"
width="100%"
height="100%">
<mx:Label text="Four" />
</mx:VBox>
<mx:VBox id="v5"
label="Five"
width="100%"
height="100%">
<mx:Label text="Five" />
</mx:VBox>
</mx:Accordion>
</mx:Application>
/**
* http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/
*/
package comps {
import mx.containers.accordionClasses.AccordionHeader;
import mx.events.FlexEvent;
public class MyAccHeader extends AccordionHeader {
public function MyAccHeader() {
super();
addEventListener(FlexEvent.INITIALIZE, accordionHeader_initialize);
}
private function accordionHeader_initialize(evt:FlexEvent):void {
enabled = data.enabled;
}
}
}
* http://blog.flexexamples.com/2008/05/30/preventing-users-from-clicking-on-an-accordion-containers-header-in-flex/
*/
package comps {
import mx.containers.accordionClasses.AccordionHeader;
import mx.events.FlexEvent;
public class MyAccHeader extends AccordionHeader {
public function MyAccHeader() {
super();
addEventListener(FlexEvent.INITIALIZE, accordionHeader_initialize);
}
private function accordionHeader_initialize(evt:FlexEvent):void {
enabled = data.enabled;
}
}
}