events - 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 或标签栏 selectedIndex 以编程方式更改时触发事件。我change
在 TabBar 上尝试过事件,但是使用 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>
推荐阅读
- java - Java 并发,同步。我在一个方法中增加两个变量,但它们是不同的
- r - 在 r(不是 ggplot)中使用 barplot 绘图时从列中删除某种数据
- c++ - 如何使用 ofstream c++ 替换文本文件中的特定值?
- algorithm - 棋盘上的骑士-最短路径
- python - 如何在pyspark中使用map进行rest api调用
- java - 如何在 Java 中创建对 MongoDB 没有价值的文档
- javascript - console.log 表示每次通话都成功,但 twiiter 没有显示转推
- c# - 在 C# 中合并间隔与合并距离
- mysql - 未标记空时的 SQL 案例
- flutter - video_player 插件无法播放视频 - Flutter