Flex load Image from Network
来源:互联网 发布:网络司法拍卖变卖 编辑:程序博客网 时间:2024/05/16 13:38
在Flex中需要加载网络图片时(jpg,png,gif等)可以使用URLLoader的相关方法,具体代码如下:
<?xml version="1.0" encoding="utf-8"?><s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" creationComplete="application1_creationCompleteHandler(event)"><fx:Script><![CDATA[import mx.controls.Image;import mx.events.CloseEvent;import mx.events.FlexEvent;import mx.managers.PopUpManager;import spark.components.Scroller;import spark.components.TitleWindow;import spark.components.VGroup;import spark.layouts.HorizontalLayout;private var imgWin:TitleWindow;private var urlLoader:URLLoader = new URLLoader();protected function application1_creationCompleteHandler(event:FlexEvent):void{var urlReq:URLRequest = new URLRequest("http://www.baidu.com/img/bdlogo.gif");urlLoader.dataFormat = URLLoaderDataFormat.BINARY;urlLoader.load(urlReq);urlLoader.addEventListener(Event.COMPLETE, completeHandler);}private function completeHandler(event:Event):void {var fileName:String = "远程图片";imgWin = new TitleWindow();var layout:HorizontalLayout = new HorizontalLayout();layout.horizontalAlign = "center";layout.verticalAlign = "middle";imgWin.layout = layout;imgWin.addEventListener(CloseEvent.CLOSE,function():void{PopUpManager.removePopUp(imgWin);});imgWin.width = 800;imgWin.height = 480;imgWin.title = fileName;var img:Image = new Image();img.source = urlLoader.data;//这里使用 img.load(urlLoader.data);也可以img.name = fileName;img.addEventListener(Event.COMPLETE,onImageLoadComplete);var scroller:Scroller = new Scroller();scroller.percentHeight = 100;scroller.percentWidth = 100;var g:VGroup = new VGroup();g.horizontalAlign = "center";g.verticalAlign = "middle";g.addElement(img);scroller.viewport = g;imgWin.addElement(scroller);}private function onImageLoadComplete(e:Event):void{var img:Image = e.currentTarget as Image;//Alert.show('img width:'+img.width+',height:'+img.height+','+img.contentWidth+","+img.contentHeight);imgWin.width = img.contentWidth <= 750 ? 800 : (img.contentWidth+50);imgWin.height = img.contentHeight <= 430 ? 480 : (img.contentHeight+50);//imgWin.title = img.name;PopUpManager.addPopUp(imgWin, this, true);PopUpManager.centerPopUp(imgWin);}]]></fx:Script><fx:Declarations><!-- Place non-visual elements (e.g., services, value objects) here --></fx:Declarations></s:Application>
- Flex load Image from Network
- Live Image from Network Camera Server
- CCSPRITE:Load image from users documents folder
- How to make 9-patch image downloaded from the Network
- Could not load image referenced from a nib
- Tensorflow Image Processing Basic 2: Load Images from folder
- image load
- load image
- iOS Could not load the "111.image" image referenced from a nib in th
- Depth Map Prediction from a Single Image using a Multi-Scale Deep Network
- 【论文笔记】Depth Map Prediction from a Single Image using a Multi-Scale Deep Network
- 学习笔记-Depth Map Prediction from a Single Image using a Multi-Scale Deep Network
- Depth Map Prediction from a Single Image using a Multi-Scale Deep Network
- 快速去阴影--Fast Shadow Detection from a Single Image Using a Patched Convolutional Neural Network
- image asset:Could not load the "scene" image referenced from a nib in the bundle with identifier
- Load image/css/js locally from Webview in Android Mobile app
- Could not load the "logo.png" image referenced from a nib in the bundle with identifier
- Could not load the "" image referenced from a nib in the bundle with identifier XXXXX
- libxml2使用详解
- 串口
- python 内存管理
- 线程调度
- bfs模板
- Flex load Image from Network
- winform实现让程序只能打开一个实例(总结3方法)
- navigationController push和pop界面切换动画
- oracle 基础学习04 -----游标 包
- MYSQL OPEN_FILES_LIMIT相关设置
- Hadoop In Action笔记(逐渐更新)
- android/linux usb 摄像头获取一张图像
- c#代码规范
- SQL命令大全