/***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主要是用来做那个鼠标边框的,就是那个蓝色的边框...如果我能做出蓝色+亮色的效果就炫了.