Show
Ignore:
Timestamp:
06/05/08 08:54:24 (21 months ago)
Author:
jeroen
Message:

fixes in skinning and controlbar

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/as3/com/jeroenwijering/utils/Draw.as

    r1 r2  
    55 
    66 
     7import flash.display.DisplayObject; 
    78import flash.display.Sprite; 
     9import flash.geom.Rectangle; 
    810import flash.text.TextField; 
    911import flash.text.TextFormat; 
     
    1113 
    1214public class Draw { 
     15 
     16 
     17        /**  
     18        * Completely clear the contents of a displayobject. 
     19        * 
     20        * @param tgt    Displayobject to clear. 
     21        **/ 
     22        public static function clear(tgt:Sprite) { 
     23                var len = tgt.numChildren; 
     24                for(var i=0; i<len; i++) { 
     25                        tgt.removeChildAt(0); 
     26                } 
     27                tgt.scaleX = tgt.scaleY = 1; 
     28        }; 
     29 
     30 
     31        /**  
     32        * Clone a displayobject. 
     33        * 
     34        * @param tgt    Displayobject to clone. 
     35        * 
     36        * @return               The clone; not yet added to the displaystack. 
     37        **/ 
     38        public static function clone(tgt:DisplayObject):DisplayObject { 
     39                var cls:Class = Object(tgt).constructor; 
     40                var dup:DisplayObject = new cls(); 
     41                dup.transform = tgt.transform; 
     42                dup.filters = tgt.filters; 
     43                dup.cacheAsBitmap = tgt.cacheAsBitmap; 
     44                dup.opaqueBackground = tgt.opaqueBackground; 
     45                if(tgt.scale9Grid) { 
     46                        var rct:Rectangle = tgt.scale9Grid; 
     47                        rct.x /= 20, rct.y /= 20, rct.width /= 20, rct.height /= 20; 
     48                        dup.scale9Grid = rct; 
     49                } 
     50            return dup; 
     51        }; 
    1352 
    1453 
     
    65104 
    66105 
    67         /**  
    68         * Completely clear the contents of a displayobject. 
    69         * 
    70         * @param tgt    Displayobject to clear. 
    71         **/ 
    72         public static function clear(tgt:Sprite) { 
    73                 var len = tgt.numChildren; 
    74                 for(var i=0; i<len; i++) { 
    75                         tgt.removeChildAt(0); 
    76                 } 
    77                 tgt.scaleX = tgt.scaleY = 1; 
    78         }; 
    79  
    80  
    81106} 
    82107