Image组件 设置 URLRequestHeader

不知道为什么Image 组件不能设置类似:var header:URLRequestHeader = new URLRequestHeader("Cache-Control", "no-cache");

 

于是:

 

<textarea cols="50" rows="15" name="code" class="c-sharp:collapse:showcolumns">package com.palace.component { import com.palace.manager.AssetsManager; import com.palace.util.MyTimerUtil; import flash.display.Loader; import flash.display.MovieClip; import flash.events.Event; import flash.events.IOErrorEvent; import flash.events.ProgressEvent; import flash.net.URLRequest; import flash.net.URLRequestHeader; import flash.net.URLRequestMethod; import mx.core.UIComponent; public class CommonImage extends UIComponent implements IPalaceToolTipInterface { public function CommonImage() { super() } public var maintainAspectRatio:Boolean = false; private var ld:Loader; private var circleMovie:MovieClip; public function loadImg(url:String,noCache:Boolean=false):void { if(ld == null){ ld = new Loader(); ld.contentLoaderInfo.addEventListener(Event.COMPLETE , loadComplete); ld.contentLoaderInfo.addEventListener(ProgressEvent.PROGRESS , progressHandle); ld.contentLoaderInfo.addEventListener(IOErrorEvent.IO_ERROR , ioErrorHandle); this.addChild(ld); } var req:URLRequest = new URLRequest(url); if(noCache) { req.data = MyTimerUtil.getCurrentTime(); req.method = URLRequestMethod.POST; var header:URLRequestHeader = new URLRequestHeader("Cache-Control", "no-cache"); req.requestHeaders.push(header); } ld.load(req); } public function unloadAndStop():void { if(ld!=null){ ld.unload(); } clear() } private function loadComplete(e:Event):void { clear() check_maintainAspectRatio() } override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void { super.updateDisplayList(unscaledWidth, unscaledHeight); check_maintainAspectRatio(); } private function check_maintainAspectRatio():void { if(maintainAspectRatio &amp;&amp; ld != null &amp;&amp; ld.contentLoaderInfo != null) { // Scale the content to the size of the SWFLoader, preserving aspect ratio. var interiorWidth:Number = unscaledWidth; var interiorHeight:Number = unscaledHeight; var contentWidth:Number = ld.contentLoaderInfo.width; var contentHeight:Number = ld.contentLoaderInfo.height var x:Number = 0; var y:Number = 0; // bug 84294 a swf may still not have size at this point var newXScale:Number = contentWidth == 0 ? 1 : interiorWidth / contentWidth; var newYScale:Number = contentHeight == 0 ? 1 : interiorHeight / contentHeight; var scale:Number; if (newXScale &gt; newYScale) { x = Math.floor((interiorWidth - contentWidth * newYScale) * .5) scale = newYScale; } else { y = Math.floor((interiorHeight - contentHeight * newXScale) * .5); scale = newXScale; } // Scale by the same amount in both directions. ld.scaleX = scale; ld.scaleY = scale; } } private function progressHandle(e:ProgressEvent):void { if(circleMovie == null) { circleMovie = AssetsManager.getDisplayObject("loadingCircle") as MovieClip; this.addChild(circleMovie); } else { if(this.width &lt;= 0) { circleMovie.x = 5 } else { circleMovie.x = this.width/2- 30/2; } if(this.height &lt;= 0) { circleMovie.y = 5; } else { circleMovie.y = this.height/2-30/2 } } } private function ioErrorHandle(e:IOErrorEvent):void { clear() } private function clear():void { if(circleMovie!=null&amp;&amp;this.contains(circleMovie)) { this.removeChild(circleMovie); } if(ld != null){ ld.contentLoaderInfo.removeEventListener(Event.COMPLETE , loadComplete); ld.contentLoaderInfo.removeEventListener(ProgressEvent.PROGRESS , progressHandle); ld.contentLoaderInfo.removeEventListener(IOErrorEvent.IO_ERROR , ioErrorHandle); } } private var _toolTipType:Number public function get toolTipType():Number { return _toolTipType; } public function set toolTipType(value:Number):void { _toolTipType = value; } private var _tipWidth:Number; public function get tipWidth():Number { return _tipWidth; } public function set tipWidth(value:Number):void { _tipWidth = value; } private var _tipHeight:Number; public function get tipHeight():Number { return _tipHeight; } public function set tipHeight(value:Number):void { _tipHeight = value; } } }</textarea>

你可能感兴趣的:(image,function,header,null,url,import)