Flex中如何监测stateChange事件,将VideoDisplay中视频当前ProgressBar中状态显示在List中

Download: main.mxml
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"
  3. layout="horizontal"
  4. verticalAlign="middle"
  5. backgroundColor="white"viewSourceURL="srcview/index.html">
  6. <mx:Script>
  7. <![CDATA[
  8. import mx.collections.ArrayCollection;
  9. import mx.events.VideoEvent;
  10. [Bindable]
  11. private var arrColl:ArrayCollection = new ArrayCollection();
  12. private const VIDEO_URL:String = "http://blog.minidx.com/ext/water.flv";
  13. private function videoDisplay_stateChange(evt:VideoEvent):void {
  14. /* videoDisplay.state == evt.state */
  15. arrColl.addItem({label:videoDisplay.state});
  16. progressBar.label = evt.state;
  17. }
  18. private function button_click(evt:MouseEvent):void {
  19. /* Reset ArrayCollection object. */
  20. arrColl = new ArrayCollection();
  21. /* Set the Canvas container to visible. */
  22. canvas.visible = true;
  23. /* If video is currently playing, stop playback. */
  24. if (videoDisplay.playing) {
  25. videoDisplay.stop();
  26. }
  27. /* Set VideoDisplay control's source property and start
  28. video playback. */
  29. videoDisplay.source = VIDEO_URL;
  30. videoDisplay.play();
  31. }
  32. private function videoDisplay_playheadUpdate(evt:VideoEvent):void {
  33. progressBar.setProgress(evt.playheadTime, videoDisplay.totalTime);
  34. }
  35. ]]>
  36. </mx:Script>
  37. <mx:ApplicationControlBardock="true">
  38. <mx:Buttonid="button"
  39. label="load movie"
  40. click="button_click(event);"/>
  41. </mx:ApplicationControlBar>
  42. <mx:Canvasid="canvas" visible="false">
  43. <mx:VideoDisplayid="videoDisplay"
  44. playheadUpdateInterval="50"
  45. stateChange="videoDisplay_stateChange(event);"
  46. playheadUpdate="videoDisplay_playheadUpdate(event);"/>
  47. <mx:ProgressBarid="progressBar"
  48. label=""
  49. labelPlacement="center"
  50. mode="manual"
  51. bottom="0"
  52. horizontalCenter="0"/>
  53. </mx:Canvas>
  54. <mx:Listid="list"
  55. dataProvider="{arrColl}"
  56. width="100"/>
  57. </mx:Application>

你可能感兴趣的:(xml,Blog,Flex,ext,Adobe)