如何解决Apache Royale Jewel TabBar / SectionContent onShow或valueCommit事件,如sdk 0.9.8中一样?
我有类似的东西:
<j:states>
<js:State name="login"/>
<js:State name="loggued"/>
</j:states>
...
<j:Group includeIn="loggued" width="100%" height="100%">
<j:TabBar localId="tabbar" width="100%" change="ev_tab_change(event)">
<j:beads>
<js:ConstantBinding sourcePropertyName="tabBarDataSample" destinationPropertyName="dataProvider"/>
<j:AssignTabContent selectedContentProperty="content">
<j:content>
<j:TabBarContent width="100%" y="80" >
<royale:TB_One/>
<royale:TB_Two/>
</j:TabBarContent>
</j:content>
</j:AssignTabContent>
</j:beads>
</j:TabBar>
</j:Group>
<royale:TB_One/>
和<royale:TB_Two/>
是<j:SectionContent>
当显示TB_One或TB_Two或以编程方式更改tabbar selectedIndex时,我需要触发一个事件。
我已经在TabBar上尝试过change
事件,但是使用selectedIndex进行更改时不会触发该事件
有onShow事件或valueCommit吗?
(暂时tabbar.dispatchEvent(new Event("change"));
可以通过编程方式更改selectedIndex来达到目的)
使用的SDK为0.9.8
致谢
解决方法
您可以执行以下操作:
<!-- The TabBar -->
<j:TabBar initComplete="tabbarInitialized(event)"/>
...
<!-- Buttons to change the content programatically -->
<j:Button click="selectContentByIndex(0)" text="0"/>
<j:Button click="selectContentByIndex(1)" text="1"/>
...
<!-- as3 code in script -->
<fx:Script>
<![CDATA[
import org.apache.royale.events.Event;
// when tabbar is initialized make tabbar listen for internal event "selectionChanged"
// this is the event to use for programmatic changes
public function tabbarInitialized(event:Event):void
{
event.target.addEventListener("selectionChanged",contentChanged);
}
// The button change the selection programmatically
public function selectContentByIndex(index:int):void
{
tabbar.selectedIndex = index;
}
// Here run the code you want. I simply trace the new tabbat selected index and the item
// but you can calculate the content and operate over tha visual component
public function contentChanged(event:Event):void
{
trace("index:",tabbar.selectedIndex,"content:",tabbar.selectedItem);
}
]]>
</fx:Script>
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。