Asp.net|web|web Service yesterday installed Flash MX Pro, looked at the next introduction, did add a lot of new features, add a lot of data components, and later feel asp.net development Web services so simple, so whim: I do not use C # and Flash to make a player ah. Here are some simple principles.
Write a Web service in C # that lists the. mp3 files for a given directory (mainly with some members of the System.IO) and adds it to a ArrayList, and finally publishes the ArrayList as a Web service. Then use Flash MX 2004 to create a flash document, get the Web service just published with the Webserviceconnector component, and then bind the returned results to the Flash list component, and finally, add an action to the list component. Let it double-click the mp3 file to play.
One,
Developing Web
Service
The specific code is as follows, very simple, no longer said, Web services development We are very familiar with, don't say such a simple example. Here is a new mp3 folder in the root directory of the site, and then put some MP3 files inside, and finally preview the test of this Web service, the preview of the address specific to the virtual directory you established the path, I have the following.
Http://onlytiancai/bak/flashmp3/mp3services.asmx
<%@ Webservice language= "C #" class= "Mp3service"%>
Using System;
Using System.Collections;
Using System.Web.Services;
Using System.IO;
public class Mp3Service:System.Web.Services.WebService
{
Public Mp3service ()
{
}
[WebMethod]
Public ArrayList GETMP3 ()
{
ArrayList mp3list =new ArrayList ();
String mp3path = Server.MapPath ("MP3");
Try
{
DirectoryInfo di = new DirectoryInfo (Mp3path);
Fileinfo[] fi = di. GetFiles ();
foreach (FileInfo fitemp in FI)
{
if (fiTemp.Extension.ToLower () = = ". mp3" | | FiTemp.Extension.ToLower () = = ". wma")
{
Mp3list.add (Fitemp.name);
}
}
}
catch (Exception e)
{
Console.WriteLine ("The process failed: {0}", e.tostring ());
}
return mp3list;
}
}
Second, the development of Flash client
Open Flash Create a new flash document, press CTRL+SHIFT+F10 to open the Web Service panel, click the Add Web Service icon on the left, and add the first step to the Web service address that we developed, as follows.
After the success of the addition, the Web Services panel is shown below.
[1] [2] [3] Next page