我編寫了一個組件,它顯示文件名,縮略圖並具有一個用於加載/播放文件的按鈕。該組件是綁定到中繼器的數據。我怎樣才能讓按鈕事件觸發主應用程序並告訴它要播放哪個文件?Adobe Flex組件事件
5
A
回答
1
在您的自定義組件上,您可以收聽按鈕單擊事件,然後生成一個自定義事件,其中包含有關要播放的文件的信息。然後,您可以將事件的bubbles屬性設置爲true,並從您的自定義組件中分派自定義事件。氣泡屬性將使您的事件浮出顯示列表併到達主應用程序。現在在您的主應用程序中,您可以收聽該事件並播放正確的文件。希望這可以幫助。
1
想通了(最終)
定製組件
<?xml version="1.0" encoding="utf-8"?>
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" x="0" y="0" width="215" height="102" styleName="leftListItemPanel" backgroundColor="#ECECEC" horizontalScrollPolicy="off" verticalScrollPolicy="off">
<mx:Script>
<![CDATA[
[Bindable] public var Title:String = "";
[Bindable] public var Description:String = "";
[Bindable] public var Icon:String = "";
[Bindable] public var FileID:String = "";
private function viewClickHandler():void{
dispatchEvent(new Event("viewClick", true));// bubble to parent
}
]]>
</mx:Script>
<mx:Metadata>
[Event(name="viewClick", type="flash.events.Event")]
</mx:Metadata>
<mx:Label x="11" y="9" text="{String(Title)}" styleName="listItemLabel"/>
<mx:TextArea x="11" y="25" height="36" width="170" backgroundAlpha="0.0" alpha="0.0" styleName="listItemDesc" wordWrap="true" editable="false" text="{String(Description)}"/>
<mx:Button x="20" y="65" label="View" click="viewClickHandler();" styleName="listItemButton" height="22" width="60"/>
<mx:LinkButton x="106" y="68" label="Details..." styleName="listItemLink" height="18"/>
<mx:HRule x="0" y="101" width="215"/>
中繼器
<mx:Canvas id="pnlSpotlight" label="SPOTLIGHT" height="100%" width="100%" horizontalScrollPolicy="off">
<mx:VBox width="100%" height="80%" paddingTop="2" paddingBottom="1" verticalGap="1">
<mx:Repeater id="rptrSpotlight" dataProvider="{aSpotlight}">
<sm:SmallCourseListItem
viewClick="PlayFile(event.currentTarget.getRepeaterItem().fileName);"
Description="{rptrSpotlight.currentItem.fileDescription}"
FileID = "{rptrRecentlyViewed.currentItem.fileName}"
Title="{rptrSpotlight.currentItem.fileTitle}" />
</mx:Repeater>
</mx:VBox>
</mx:Canvas>
處理功能
private function PlayFile(fileName:String):void{
Alert.show(fileName.toString());
}
相關問題
- 1. Adobe Flex極端組件
- 2. Adobe導遊組件Flex
- 3. Adobe Flex計時器事件
- 4. Adobe Flex/Actionscript事件處理命令
- 5. Adobe Flex的切換組件全屏
- 6. Adobe Flex DeepLinking
- 7. Adobe Flex RichTextEditor
- 8. Adobe Flex arraycollection
- 9. Adobe Edge onload事件
- 10. Adobe Flex key capture
- 11. Adobe Flex日期
- 12. Adobe flex layout redraw
- 13. Adobe Flex的unicodeRange
- 14. Adobe Flex Charting SDK
- 15. Adobe Flex Datagrid:addEventListener MouseEvent.CLICK
- 16. Adobe Flex的.swf文件緩存
- 17. Adobe Flex空氣文件預覽
- 18. Adobe Flex的文件上傳
- 19. Adobe Flex - 生成XML文件
- 20. Adobe Flex在電子郵件中?
- 21. Adobe Flex:從組件MXML中的主應用程序訪問結果事件
- 22. Adobe Illustrator - 文件分組
- 23. Adobe CQ5全球組件
- 24. Adobe AIR HTML組件 - socket.io
- 25. Adobe Flex - 標籤值上的MouseDown事件
- 26. Adobe Flex:啓用= false的spark組件的工具提示
- 27. Adobe Flex 4.5 Spark:綁定ItemRenderer組件到父
- 28. Adobe Flex的設置樣式爲組件的狀態
- 29. Adobe Flex - 如何在圖像的「窗口」中嵌入組件?
- 30. Adobe Flex中的HitTest