이미지 돌리거나 클때 찌그러지는 현상 방지

|


여기저기 구경하다가 지돌스타님 블로그에서 유용할거 같은 as 퍼옴;;

문제되면 자삭 할께요!!

원문보기!!!


package
{
       import flash.display.Bitmap;
       import flash.display.DisplayObject;
       import flash.events.Event;
       import flash.events.IOErrorEvent;
       import flash.events.SecurityErrorEvent;       
       import mx.controls.Image;

       public class imgSmo extends Image
       {
             public function imgSmo()
             {
                    super();
             }
             
             override public function load(url:Object=null):void
             {
                    super.load(url);
                    addEventHandlers();
             }
            
             private function completeEventHandler(event:Event):void
             {
                    var content:DisplayObject = this.content as DisplayObject;
                    var bitmap:Bitmap;
                    if(content)
                    {
                           bitmap = content as Bitmap;
                           if( bitmap )
                                 bitmap.smoothing=true;
                    }
                    removeEventHandlers();
             }
             
             override public function set source(value:Object):void
             {
                    var bitmap:Bitmap = value as Bitmap;
                    if( bitmap )
                    {
                           bitmap.smoothing = true;   
                    }
                    super.source = value;
             }
             
             private function ioEventHandler(event:IOErrorEvent):void
             {
                    removeEventHandlers();
             }
             
             private function securityErrorEventHandler(event:SecurityErrorEvent):void
             {
                    removeEventHandlers();
             }
             
             private function addEventHandlers():void
             {
                    this.addEventListener(Event.COMPLETE, completeEventHandler);
                    this.addEventListener(IOErrorEvent.IO_ERROR, ioEventHandler);
                    this.addEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorEventHandler);
             }
             
             private function removeEventHandlers():void
             {
                    this.removeEventListener(Event.COMPLETE, completeEventHandler);
                    this.removeEventListener(IOErrorEvent.IO_ERROR, ioEventHandler);
                    this.removeEventListener(SecurityErrorEvent.SECURITY_ERROR, securityErrorEventHandler);
             }
       }
}


유용하게 쓰겠습니다^^
Trackback 0 And Comment 0