ººÍø£ºflash¼ÓÔØÍⲿͼƬµÈ±ÈËõ·ÅÀà(as3) -µçÄÔ×ÊÁÏ

µçÄÔ×ÊÁÏ Ê±¼ä£º2019-01-01 ÎÒҪͶ¸å
¡¾www.unjs.com - µçÄÔ×ÊÁÏ¡¿

   

    ÿ´Î×öÏà²áÀàµÄflashµÄʱºò£¬Í¼Æ¬¼ÓÔØÍê±ÏÖ®ºó¶¼ÒªÐ´µÈ±ÈËõ·ÅµÄº¯ÊýÀ´´¦Àí¼ÓÔØÍ¼Æ¬£¬

ººÍø£ºflash¼ÓÔØÍⲿͼƬµÈ±ÈËõ·ÅÀà(as3)

¡£

    ½ñÌìÓÖÓöµ½ÁË£¬Ò²²»ÖªÏþÄĸù½î²»¶ÔÁË£¬ÅªÁËÊ®¼¸·ÖÖÓÀÏÊÇËã·¨Óв»ÕýÈ·¡£ºÃºÃµÄÒ»¸öƯÁÁMM ͼƬ±»¸ãµÄ²Ò²»È̶á£ËùÒÔдÁËÕâ¸öÀà Ö±½Ó·Åµ½ÎÒµÄas°üÀÒÔºó²»ÒªÔÙÕâôÂé·³ÁË¡£

    Ìùһϣ¬ÄÜÓõÄÅóÓѾÍÓÃÒ»Ó᣿´²»ÉÏÑÛµÄÒ²²»ÒªÅÄש°¡¡£

    ϱßÊÇ´úÂë¼°×¢ÊÍ˵Ã÷£º

    /*

    µÈ±ÈËõ·Å

    as1984 - qq:38657783

    20091221

    ÇëÁôÐİü·¾¶£¬ÎÒµÄas°ü¶¼·ÅÔÚtoolsĿ¼Ï¡£ËùÒÔ°üµÄ·¾¶ÊÇ tools

    ¼ÙÈçÄãµÄ·¾¶²»Ò»Ñù£¬ÇëÁôÐÄÐÞ¸Ä

    */

    package tools

    {

    public class imgzoom {

    // ±äÁ¿ÉùÃ÷

    private var isZoom:Boolean;//Äܲ»ÄÜËõ·Å

    private var srcWidth:Number;//ԭʼ¿í

    private var srcHeight:Number;//ԭʼ¸ß

    private var maxWidth:Number;//ÏÞ¶¨¿í

    private var maxHeight:Number;//ÏÞ¶¨¸ß

    private var newWidth:Number;//пí

    private var newHeight:Number;//иß

    public function imgzoom(srcWidth:Number,srcHeight:Number,maxWidth:Number,maxHeight:Number):

    void

    {

    this.srcWidth=srcWidth;//È¡µÃԭʼ¿í¶È

    this.srcHeight=srcHeight;//È¡µÃԭʼ¸ß¶È

    this.maxWidth=maxWidth;//È¡µÃÏÞ¶¨¿í¶È

    this.maxHeight=maxHeight;//È¡µÃÏÞ¶¨¸ß¶È

    if(this.srcWidth>0 && this.srcWidth>0){//¼ì²éͼƬ¸ß¶ÈÄܲ»ÄÜÕý³£

    this.isZoom=true;//¸ß¿íÕý³££¬Ö´ÐÐËõ·Å´¦Àí

    }else{

    this.isZoom=false;//²»Õý³££¬·µ»Ø0

    }

    conductimg();//Ö´ÐÐËõ·ÅËã·¨

    }

    public function width():Number{//·µ»Ø´¦ÀíºóµÄ¿í¶È£¬¾«È·µ½2¸öСÊýµã

    return Number(this.newWidth.toFixed(2));

    }

    public function height():Number{//·µ»Ø´¦ÀíºóµÄ¸ß¶È£¬¾«È·µ½2¸öСÊýµã

    return Number(this.newHeight.toFixed(2));

    }

    private function conductimg():void{

    if(this.isZoom){//¼ÙÈç¸ß¿íÕý³££¬¿ªÊ¼¼ÆËã

    if(this.srcWidth/this.srcHeight>=this.maxWidth/this.maxHeight){

    //±È½Ï¸ß¿í±ÈÀý£¬È·¶¨ÒÔ¿í»òÕßÊǸßΪ»ù׼ʵÐмÆË㣬

µçÄÔ×ÊÁÏ

¡¶ººÍø£ºflash¼ÓÔØÍⲿͼƬµÈ±ÈËõ·ÅÀà(as3)¡·(https://www.unjs.com)¡£

    if(this.srcWidth>this.maxWidth){//ÒÔ¿íΪ»ù×¼¿ªÊ¼¼ÆË㣬

    //µ±¿í¶È´óÓÚÏÞ¶¨¿í¶È£¬¿ªÊ¼Ëõ·Å

    this.newWidth=this.maxWidth;

    this.newHeight=(this.srcHeight*this.maxWidth)/this.srcWidth

    }else{

    //µ±¿í¶ÈСÓÚÏÞ¶¨¿í¶È£¬Ö±½Ó·µ»ØÔ­Ê¼ÊýÖµ¡£

×îÐÂÎÄÕÂ