• flex 图片自动适应大小


    <!-- http://blog.flexexamples.com/2007/08/07/creating-full-screen-flex-applications/ -->
    <mx:Application name="FullScreen_test" xmlns:mx="http://www.adobe.com/2006/mxml" 
        layout
    ="absolute" applicationComplete="app(event)"  width="800" height="500">
        
    <mx:Script>
        
    <![CDATA[
                import mx.controls.Alert;
                import mx.events.EffectEvent;
                import mx.events.FlexEvent;
                
                
                protected function app(event:FlexEvent):void
                {
                    img.source="3.jpg";
                    img.addEventListener(Event.COMPLETE, imgLoadFinish);
                }
                private function imgLoadFinish(evt:Event):void
                {
                    //原始图片的大小
                    var real_Number = img.contentWidth;
                    var real_height:Number = img.contentHeight;
                    //容器的大小
                    var flashWidth:Number = this.width;
                    var flashHeight:Number = this.height;
                    //比值
                    var w_bi:Number = real_width/width;
                    var h_bi:Number = real_height/height;
                   
                    if(w_bi < 1 && h_bi <1)
                    {
                        img.width = img.content.width;
                        img.height = img.content.height;
                    }
                    else
                    {
                        if(w_bi > h_bi)
                        {
                            img.width = flashWidth;
                            img.height = real_height * flashWidth / real_width;
                        }
                        else
                        {
                            img.height = flashHeight;
                            img.width = real_width * flashHeight / real_height;
                        }
                    }
                    img.x = (flashWidth - img.width) / 2;
                    img.y = (flashHeight - img.height) / 2;
                }
            
    ]]>
        
    </mx:Script>
        
    <mx:Canvas x="0" y="0" width="100%" height="100%" id="divMain" horizontalScrollPolicy="off" verticalScrollPolicy="off" >
            
    <mx:Image id="img" />
        
    </mx:Canvas>
    </mx:Application>

  • 相关阅读:
    解决vs code 内置终端,字体间隔过大问题。(linux centos7 ubuntu成功)
    安装Epson打印机但因lsb依赖错误而中断的驱动程序
    ubuntu 权限不够,解决办法,无法获得锁 /var/lib/dpkg/lock
    ubuntu 安装WPS
    GNU GRUB引导的默认启动项是ubuntu
    网络编程基础
    反射、特殊双下方法、单例模式
    异常处理
    封装、多态、类的约束、类的私有成员
    多继承、经典类与新式类、新式类的C3算法详解
  • 原文地址:https://www.cnblogs.com/chixiaojin/p/2078547.html
Copyright © 2020-2023  润新知