首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 媒体动画 > flex >

FLEX 四 :选择本地文件编辑

2012-09-09 
FLEX 4 :选择本地文件编辑代码如下:?xml version1.0 encodingutf-8?application xmlns:fxhttp:

FLEX 4 :选择本地文件编辑
代码如下:<?xml version="1.0" encoding="utf-8"?><application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/halo" minwidth="1024" minheight="768" creationcomplete="init();" xmlns:mx1="library://ns.adobe.com/flex/mx"><layout><horizontallayout></horizontallayout></layout><script></script><button label="LoadImage" click="loadImage();"></button> <canvas id="canvas" width="553" height="437" bordercolor="0x000000" borderstyle="solid"></canvas></application>遇到的后续问题: 加载本地图片后舞台的大小变化。 即获得本地图片的width 和 height 等原始属性。解决办法:  通过 Loader 类 的 contentLoaderInfo 属性 : var target:LoaderInfo = evt.currentTarget as LoaderInfo;  代码如下: private function fileComplete(event:Event):void {   loder.loadBytes(file.data);   loder.contentLoaderInfo.addEventListener(Event.COMPLETE,completeHander); } private function completeHander(evt:Event):void {   var target:LoaderInfo = evt.currentTarget as LoaderInfo;   img.width = target.width;   img.height = target.height; // 即图片宽高 }

热点排行