当前位置:软件学习 > Flash >>

FLAHS+ASP扫描文件夹展示图片

用asp教程的fso(这个思路是刚才一位朋友在回贴中提到的,所以我才想起要做这个东东,呵呵)对象来扫描同文件夹下的jpg图片,并输出文件名
这里用asp输出xml格式让flash加载,虽然不不太喜欢xml,但大家都觉得它规范一些,就输出它吧

<%@language="vbscrīpt" codepage="65001"%>

<%
dim thispath,fso,fileitem,allfolder
thispath = server.mappath(request.servervariables("scrīpt_name")) '得到asp文件的路径
set fso = createobject("scrīpting.filesystemobject")'创建fso对像
set allfolder = fso.getfile(thispath).parentfolder.files '得到asp所在目录的父级对像,它就包括了这个asp和我们放的图片
response.write("<?xml version=""1.0"" encoding=""utf-8""?>")'开始输出xml
response.contenttype = "text/xml"
response.write("<path>")
for each fileitem in allfolder '想当于flash中的遍历,遍历整个对像中的元素
  if lcase(right(fileitem.name,4))=".jpg" then '如果后缀是jpg
  response.write("<url>"+fileitem.name+"</url>")'就把它的文件名输出为xml的一个新节点
  end if
next
response.write("</path>")
response.end()
%>


 

as代码

import flash.filters.blurfilter;
import flash.filters.drops教程hadowfilter;
////============初始化===========
var b_filters:blurfilter = new blurfilter(5, 5, 1);
var d_filters:dropshadowfilter = new dropshadowfilter(5, 45, 0, 80, 10, 10);
var n:number = new number();
var url_array = new array();
//这里是设置swf与asp的相对路径,虽然可以在asp中比较得出,但感觉没有必要
var path_str:string = "images/";
function go_func() {
if (n<url_array.length-1) {
  n++;
  load_func();
} else {
  trace("加载完成!");
}
}
//============mcl类===========
var _mcl:moviecliploader = new moviecliploader();
this.onloadinit = function(_mc:movieclip) {
_mc._txt.removetextfield();
_mc._width = 80;
_mc._height = 80;
_mc.filters = [b_filters, d_filters];
//============这里设置鼠标动作===========
_mc.onrollover = function() {
  this.filters = null;
};
_mc.onrollout = function() {
  this.filters = [b_filters, d_filters];
};
go_func();
};
//如果没有下面的代码,就会一个加载出错,导致后面的都不能加载,用这个可以出错时继续向下加载,源文件中我故意少了一个图片,让它出错
this.onloaderror = function(_mc:movieclip) {
_mc.createtextfield("_txt", 200, 20, 10, 60, 30);
_mc._txt.textcolor = 0xff0000;
_mc._txt.text = "加载失败!";
go_func();
};
//=========加载进度显示==============
this.onloadprogress = function(_mc:movieclip, bytesloaded:number, bytestotal:number) {
_mc.createtextfield("_txt", 200, 20, 10, 60, 30);
_mc._txt.textcolor = 0xff0000;
_mc._txt.text = math.floor((bytesloaded/bytestotal*10000)/100)+"%";
};
_mcl.addlistener(this);
//=================load函数========
function load_func() {
this.createemptymovieclip("pic_mc"+n, n+100);
//如果要改成竖向加载,只需把下面的_x _y换一下就行了
this["pic_mc"+n]._y = 30+math.floor(n/3)*100;
this["pic_mc"+n]._x = 100+n%3*100;
_mcl.loadclip(path_str+url_array[n], this["pic_mc"+n]);
}
//===========xml文件加载=========
var url_xml = new xml();
url_xml.ignorewhite = true;
url_xml.onload = function(suc) {
if (suc) {
  for (var d:number = 0; d<this.firstchild.childnodes.length; d++) {
   url_array.push(this.firstchild.childnodes[d].firstchild.nodevalue);
  }
  load_func();
} else {
  trace("xml文件加载失败!");
}
};
url_xml.load(path_str+"showjpg.asp");

补充:flash教程,动画技术
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,