时间:2010-07-26 18:16:01

标签: flex

请查看我的Flex代码的一部分:

<mx:Accordion id="accordian" width="100%" height="326" selectedIndex="0">
  <journal:ResearchJournalSection id="researchSection" width="100%"/>
  <journal:QuestionJournalSection id="questionSection" width="100%"/>
  <journal:DesignJournalSection id="designSection" width="100%"/>
</mx:Accordion>
<mx:Panel width="100%" height="129" layout="absolute" title="FAQ Area">
  <mx:Text x="0" y="10" text="What is a research question?&#xa;" width="250   

    height="20" fontWeight="bold"/>
 </mx:Panel>

它的作用是展示三种期刊(研究,问题和设计),同时还展示了一个FAQ问题小组。 目前FAQ面板总是显示“什么是研究问题”,但是我想让它显示与用户当前选择的日志相对应的内容,例如,如果用户现在点击“设计日记”,那么常见问题解答区域中的相应文本应为“什么是关于设计的重要内容?”。

希望我事先说清楚,谢谢!

1 个答案:

答案 0 :(得分:3)

我的Flex有点生疏,但您应该能够在Accordion上添加一个change="myFunction()"属性,指向一个Actionscript函数:

myFunction() {
  var selectedChild = accordian.selectedChild; //here 'accordian' is the id of your mx:Accordion
  if (selectedChild.id == 'researchSection') {
      myText.text = "What is a research question?"; //your mx:Text tag should have the id 'myText'
  } else if (selectedChild.id == 'questionSection') {
      myText.text = "What is a question question?"; //question question? that doesn't seem right; anyway you'll put something else here
  } else if (selectedChild.id == 'designSection') {
      myText.text = "What is a design question?";
  }
}

该函数应放在mxml文件中的脚本标记中。