?? bytearrayimage.as
字號(hào):
package Compnents
{
import flash.display.Loader;
import flash.events.Event;
import flash.net.URLRequest;
import flash.system.LoaderContext;
import flash.utils.ByteArray;
import mx.controls.Image;
//把ByteArray傳給loadBytes方法就好了
public class ByteArrayImage extends mx.controls.Image
{
private var _loader:Loader = new Loader();
public function Image():void {
}
override protected function createChildren():void {
addChild(_loader);
_loader.cacheAsBitmap=true;
}
public function loadBytes(bytes:ByteArray, context:LoaderContext = null):void {
//_loader.unload();
_loader.loadBytes(bytes, context);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBytesLoaded);
}
public function loadBytes2(bytes:ByteArray, context:LoaderContext = null):void {
_loader.loadBytes(bytes, context);
_loader.contentLoaderInfo.addEventListener(Event.COMPLETE, onBytesLoaded2);
}
public function unloadBytes(req:URLRequest):void{
_loader.load(req);
}
private function onBytesLoaded( e:Event ):void {
width = e.target.width;
height = e.target.height;
}
private function onBytesLoaded2( e:Event ):void {
// width = 162 ;
//height = 166;
if (e.target.width > this.width){
_loader.content.scaleX = 0.2;
_loader.content.scaleY = 0.2;
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -