<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="completeHandler()">
<fx:Declarations>
<!-- 将非可视元素(例如服务、值对象)放在此处 -->
</fx:Declarations>
<fx:Script>
<![CDATA[
import com.esri.ags.layers.supportClasses.AttachmentInfo;
import com.esri.events.BaseEvent;
import mx.core.UIComponent;
[Bindable]
public var enterprise_name_label:String = "";
[Bindable]
public var remarks_label:String = "";
[Bindable]
public var url:String = "";
private var nc:NetConnection;
private var ns:NetStream;
private var video:Video;
private var meta:Object;
private var uic:UIComponent;
private function init():void {
//
view.removeAllChildren();
if(ns != null){
ns.pause();
ns = null;
}
var nsClient:Object = {};
nsClient.onMetaData = ns_onMetaData;
nsClient.onCuePoint = ns_onCuePoint;
nc = new NetConnection();
nc.connect(null);
ns = new NetStream(nc);
ns.play("assets/images/20120507_120410.mp4");
ns.client = nsClient;
video = new Video();
video.attachNetStream(ns);
uic = new UIComponent();
uic.addChild(video);
view.addChild(uic);
}
private function ns_onMetaData(item:Object):void {
trace("meta");
meta = item;
// Resize Video object to same size as meta data.
video.width = 300;
video.height = 200;
// Resize UIComponent to same size as Video object.
uic.width = video.width;
uic.height = video.height;
}
private function ns_onCuePoint(item:Object):void {
trace("cue");
}
private function completeHandler():void{
BaseEvent.addListener(BaseEvent.ATTACHMENTINFO,setimageHandler);
BaseEvent.addListener(BaseEvent.VIDEO_STOP,cancelHandler);
}
private function setimageHandler(event:BaseEvent):void{
if(ns != null){
ns.pause();
ns = null;
}
view.removeAllChildren();
var img:Image = new Image();
img.source = (event.data as AttachmentInfo).url;
img.visible = true;
img.width = 200;
img.height =100;
view.addChild(img);
}
private function cancelHandler(event:BaseEvent):void{
if(ns != null){
ns.pause();
ns = null;
}
}
]]>
</fx:Script>
<s:Rect top="0" bottom="0" left="0" right="0">
<s:fill>
<s:SolidColor color="0xf0f0f0"/>
</s:fill>
</s:Rect>
<mx:Form width="100%" height="100%">
<mx:FormItem label="备注:" horizontalAlign="right">
<s:Label text="{remarks_label}" id="remarks"/>
</mx:FormItem>
<mx:FormItem label="附件:" horizontalAlign="right">
<mx:HBox id="hboximg" width="100%" height="100%" maxWidth="200">
</mx:HBox>
<mx:HBox id="hboxvedio" width="100%" height="100%" maxWidth="200">
<s:Image id="img1" source="assets/images/movie.png" click="init()"/>
</mx:HBox>
</mx:FormItem>
<mx:FormItem horizontalAlign="right">
<mx:HBox id="view" width="100%" height="100%">
</mx:HBox>
</mx:FormItem>
</mx:Form>
</s:Group>
Flex视频播放及其控制视频大小显示
最新推荐文章于 2021-06-23 07:31:13 发布