I used the fso in the asp tutorial (this idea was mentioned by a friend in the reply post just now, so I remembered to do this stuff, haha) to scan jpg images in the same folder, output file name
Here, we use asp to output xml format for flash loading. Although we do not like xml very much, we all think it is more standard. Just output it.
<% @ Language = "vbscr sans pt" codepage = "65001" %>
<%
Dim thispath, fso, fileitem, allfolder
Thispath = server. mappath (request. servervariables ("scr using pt _ name") 'to obtain the path of the asp file
Set fso = createobject ("scr effecpting. filesystemobject") 'Create a fso object
Set allfolder = fso. getfile (thispath). parentfolder. files 'to get the parent class object of the asp directory, which includes the asp and the image we put.
Response. write ("<? Xml version = "" 1.0 "" encoding = "" UTF-8 ""?> ") 'Start to output xml
Response. contenttype = "text/xml"
Response. write ("<path> ")
For each fileitem in allfolder 'to traverse the elements of the entire object in flash
If lcase (right (fileitem. name, 4) = ". jpg" then' if the suffix is jpg
Response. write ("<url>" + fileitem. name + "</url>") 'outputs the file name as a new node in xml.
End if
Next
Response. write ("</path> ")
Response. end ()
%>
As Code
Import flash. filters. blurfilter;
Import flash. filters. drops tutorial hadowfilter;
//// ================= Initialization ==============
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 ();
// Here is the relative path between swf and asp. Although it can be compared in asp, it is unnecessary.
Var path_str: string = "images /";
Function go_func (){
If (n <url_array.length-1 ){
N ++;
Load_func ();
} Else {
Trace ("loaded! ");
}
}
// ================ Mcl class ==============
Var _ mcl: movi1_loader = new movi1_loader ();
This. onloadinit = function (_ mc: movieclip ){
_ Mc. _ txt. removetextfield ();
_ Mc. _ width = 80;
_ Mc. _ height = 80;
_ Mc. filters = [B _filters, d_filters];
// ================ Here, set the mouse action ================
_ Mc. Onrolover = function (){
This. filters = null;
};
_ Mc. Onrolout = function (){
This. filters = [B _filters, d_filters];
};
Go_func ();
};
// If the following code is not available, a loading error will occur, resulting in the subsequent loading failure. If this error can be used, the next loading will continue. In the source file, I intentionally missed an image, make it wrong
This. onloaderror = function (_ mc: movieclip ){
_ Mc. createtextfield ("_ txt", 200, 20, 10, 60, 30 );
_ Mc. _ txt. textcolor = 0xff0000;
_ Mc. _ txt. text = "loading failed! ";
Go_func ();
};
// =========== Loading progress display ==================
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 ========
Function load_func (){
This. createemptymovieclip ("pic_mc" + n, n + 100 );
// If you want to change to vertical loading, you only need to change the following _ 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 file loading ========
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 file loading failed! ");
}
};
Url_xml.load (path_str + "showjpg. asp ");