flash on 2013-5-17

by xzardaz
♥0 | Line 25 | Modified 2013-05-18 00:15:36 | MIT License
play

ActionScript3 source code

/**
 * Copyright xzardaz ( http://wonderfl.net/user/xzardaz )
 * MIT License ( http://www.opensource.org/licenses/mit-license.php )
 * Downloaded from: http://wonderfl.net/c/cqLR
 */

/*
The MIT License

Copyright (c) 2009 Tri Nguyen - Midnight Projects

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/

package aaaa {

    // IMPORTS

    import flash.display.BitmapData;
    import flash.display.Bitmap;
    import flash.geom.Matrix
    import flash.display.MovieClip;
    import flash.geom.Rectangle; 
    import flash.geomPoint;
    
    /**
    * Static class for image capturing using BitmapData
    *
    * <p>
    * <b>Author: </b>Tri Nguyen<br/>
    * <b>Version: </b>1.0<br/>
    * <b>Modified: </b>01/12/2009
    * </p>
    */
    public class aaaa {

        // PROPERTIES

        //------------------------------------------------------------------------------------------------------------------------------------------------------

        // CONSTRUCTOR

        public function Screen() {

        }


        //------------------------------------------------------------------------------------------------------------------------------------------------------

        // GETTERS / SETTERS

        //------------------------------------------------------------------------------------------------------------------------------------------------------

        // PUBLIC METHODS
        
        /**
         * returns a bitmap from a target display object
         * @param $target:DisplayObject The target of the image to be copied<br/>
         * @param $x:Number - the x value of the source image to capture<br/>
         * @param $y:Number - the y value of the source image to capture<br/>
         * @param $width:Number - the desired width of the image to capture<br/>
         * @param $height:Number - the desired height of the image to capture
         * @usage Screen.capture(sourceMC, sourceMC.x, sourceMC.y, sourceMC.width, sourceMC.height});
         */
         
        public static function capture($target:*, $x:Number = 0, $y:Number = 0, $width:Number = 0, $height:Number = 0):Bitmap {
            var bmd0:BitmapData = new BitmapData($target.width, $target.height, true, 0x00000000);
            var bmd1:BitmapData = new BitmapData($width, $height, true, 0x00000000);
            bmd0.draw($target, new Matrix());
            var rect:Rectangle = new Rectangle($x, $y, $width, $height);
            var pt:Point = new Point(0, 0);
            bmd1.copyPixels(bmd0, rect, pt);
            var bm:Bitmap = new Bitmap(bmd1);
            return bm;
        }

        //------------------------------------------------------------------------------------------------------------------------------------------------------
        public function toString():String {
            return "[Screen]";
        }

        //------------------------------------------------------------------------------------------------------------------------------------------------------

        // PROTECTED METHODS

        //------------------------------------------------------------------------------------------------------------------------------------------------------

        // EVENT HANDLERS
    }
}