flex中videodisplay的简单应用

来源:互联网 发布:广东唯一网络 编辑:程序博客网 时间:2024/05/20 17:10

解决问题:根据不同的识别号获取统一路径下不同的视频

解决关键:将videodisplay的source成设置与变量相关

主要代码如下:每次打开该borderContainer时,视频展示会随着mytext的不同切换不同的视频

<?xml version="1.0" encoding="utf-8"?><s:BorderContainer xmlns:fx="http://ns.adobe.com/mxml/2009"                    xmlns:s="library://ns.adobe.com/flex/spark"                    xmlns:mx="library://ns.adobe.com/flex/mx" width="400" height="300"                    creationComplete="bordercontainer1_creationCompleteHandler(event)" >    <fx:Script>        <![CDATA[            import mx.controls.Alert;            import mx.events.FlexEvent;            public var mytext:String;            protected function image1_clickHandler(event:MouseEvent):void            {                this.visible=false;            }               protected function bordercontainer1_creationCompleteHandler(event:FlexEvent):void            {                var lujing:String="assets/"+ mytext +".mp4";                                vd1.source=lujing;            }        ]]>    </fx:Script>    <fx:Declarations>        <!-- 将非可视元素(例如服务、值对象)放在此处 -->    </fx:Declarations>    <s:VideoDisplay id="vd1" x="-1" y="-1" width="314" height="230" chromeColor="#9A9898"/>    <s:Image x="286" y="-2" width="29" height="32" source="assets/关闭(1).png" buttonMode="true" click="image1_clickHandler(event)"/></s:BorderContainer>
0 0