• as3动态加载多张图片,自动缩放并加鼠标边框![新手]


    /***imgload.as*****/
    package{
    import flash.display.Loader;
    import flash.display.Sprite;
    import flash.net.URLRequest;
    import flash.display.LoaderInfo;
    import flash.events.*;
    import flash.display.MovieClip;
    public class imgload extends Sprite
    {
       private var list:Array,img:Array;
       private var v_int=92;
       private var v_height:int=107;
       private var count:Number=0;
       public function imgload():void
       {
        list = new Array();
        img = new Array();
       }
       public function loadImg(str:String):void
       {
        list = str.split(',');
        for(var i:int=0;i<list.length;i++)
        {
         var loadimg:Loader = new Loader();
         loadimg.name = "loadimg"+i;
         var url:String = "image/t"+list[i]+".jpg";
         loadimg.load(new URLRequest(url));
         img.push(loadimg);
        }
        addListen(img);
       }
       public function addListen(loadarry:Array):void
       {
        for(var i:int=0;i<loadarry.length;i++)
        {
         loadarry[i].contentLoaderInfo.addEventListener(Event.COMPLETE,onLoadComplete);
        }
       }
       public function onLoadComplete(e:Event):void
       {
        var l:Loader = e.target.loader;
        var n_int = l.content.width;
        var n_height:int = l.content.height;
        var n_num:Number = v_width/v_height;

        var t_int = n_width;
        var t_height:int = n_height;
        var rate:int;
        var n_state:Boolean = n_width>v_width || n_height>v_height ? true:false;
       
        if(n_state)
        {
         if(n_width/n_height>n_num)
         {
          rate = n_width/v_width;
          t_width = v_width;
          t_height = n_height/rate;
         }
         else if(n_width/n_height<n_num)
         {
          rate = n_height/v_height;
          t_height = v_height;
          t_width = n_width/rate;
         }
        }
        l.content.width=t_width-2;
        l.content.height=t_height-2;
        l.content.x = 1;
        l.content.y = 1;
       
        var boxmc:imgbox = new imgbox();
        boxmc.width = t_width;
        boxmc.height = t_height;
        boxmc.alpha=0;
        var mc:MovieClip = new MovieClip();
        mc.addChild(boxmc);
        mc.width=t_width;
        mc.height=t_height;
        mc.addChild(l);
        mc.x=100;
        mc.y=count;
        mc.addEventListener(MouseEvent.MOUSE_OVER,function(){boxmc.alpha=100;mc.buttonMode=true;mc.useHandCursor=true;});
        mc.addEventListener(MouseEvent.MOUSE_OUT,function(){boxmc.alpha=0;});
        addChild(mc);
        count = count+t_height;
       }
    }
    }

    /***index.fla 第一针.***/

    var str:String = "1024,1226,1428,newyearLogo";//图片列表.因为我做的是php+as通信所以这个地方的参数以后是由php来完成的.当 然试验的时候图片的名字为 t1024.jpg,t1226.jpg,t1428.jpg,tnewyearLogo.jpg并放在image文件夹里.
    var k:imgload = new imgload();
    k.loadImg(str);
    addChild(k);

    /***库里的文件:***/

    mc名-> imgbox [类名:imgbox]
    说明:这个imgbox主要是用来做那个鼠标边框的,就是那个蓝色的边框...如果我能做出蓝色+亮色的效果就炫了.

  • 相关阅读:
    JavaScript+IndexedDB实现留言板:客户端存储数据
    怎么限制Google自动调整字体大小
    《互联网时代》告诉我的互联网简史(二)
    《互联网时代》告诉我的互联网简史(一)
    CSS换行:word-wrap、word-break和text-wrap区别
    php中的字符串和正则表达式
    php数组使用小结
    问题:关于一个贴友的js留言板的实现
    问题:关于坛友的一个定时重复显示和隐藏div的实现
    使用union 外加count
  • 原文地址:https://www.cnblogs.com/top5/p/1667787.html
Copyright © 2020-2023  润新知