本文实例讲述了asp.net+xml+flash实现的图片展示效果。分享给大家供大家参考,具体如下:

第一步:首先引入命名空间:(vs08环境中)

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text; //(需要引入的)
using System.Xml; //(需要引入的)

第二步:前台页面的使用(需要index.swf文件):

<div align="center" id="qiyeyuangong" style="float:left;" runat="server">
 <object
  classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0"
  width="710"
  height="625"
  id="tech"
  align="middle" >
  <param name="wmode" value="transparent">
  <param name="allowScriptAccess" value="sameDomain" />
  <param name="movie" value="index.swf" />
  <param name="quality" value="high" />
  <embed
   src="/UploadFiles/2021-04-02/index.swf">

第三步:生成xml文件方法:

//生成Xml文件
public void xmlGetPic()
{
    //删除slides.xml文件
    string fileXml = "slides.xml";
    //if (File.Exists(Server.MapPath(fileXml)))
    //{
    //  File.Delete(Server.MapPath(fileXml));
    //}
    if (!File.Exists(Server.MapPath(fileXml)))
    {
      // Create a new XmlTextWriter instance
      XmlTextWriter writer = new
      XmlTextWriter(Server.MapPath("slides.xml"), Encoding.UTF8);
      // start writing!
      writer.WriteStartDocument();
      writer.WriteStartElement("flash_parameters");
      writer.WriteStartElement("preferences");
      writer.WriteStartElement("global");
      writer.WriteStartElement("basic_property");
      writer.WriteAttributeString("movieWidth", "710");
      writer.WriteAttributeString("movieHeight", "625");
      writer.WriteAttributeString("html_title", "Title");
      writer.WriteAttributeString("loadStyle", "Pie");
      writer.WriteAttributeString("startAutoPlay", "true");
      writer.WriteAttributeString("backgroundColor", "0xffffff");
      writer.WriteAttributeString("anvsoftMenu", "false");
      writer.WriteAttributeString("hideAdobeMenu", "false");
      writer.WriteAttributeString("photoDynamicShow", "true");
      writer.WriteAttributeString("enableURL", "true");
      writer.WriteAttributeString("transitionArray", "");
      writer.WriteEndElement();
      writer.WriteStartElement("title_property");
      writer.WriteAttributeString("photoTitle", "false");
      writer.WriteAttributeString("photoTitleX", "5");
      writer.WriteAttributeString("photoTitleY", "5");
      writer.WriteAttributeString("photoTitleSize", "15");
      writer.WriteAttributeString("photoTitleFont", "Verdana");
      writer.WriteAttributeString("photoTitleColor", "0xffffff");
      writer.WriteEndElement();
      writer.WriteStartElement("music_property");
      writer.WriteAttributeString("path", "");
      writer.WriteAttributeString("stream", "true");
      writer.WriteAttributeString("loop", "true");
      writer.WriteEndElement();
      writer.WriteStartElement("photo_property");
      writer.WriteAttributeString("topPadding", "0");
      writer.WriteAttributeString("bottomPadding", "65");
      writer.WriteAttributeString("leftPadding", "0");//定义显示的图片距离flash左边的距离
      writer.WriteAttributeString("rightPadding", "0");//定义显示的图片距离flash右边的距离
      writer.WriteEndElement();
      writer.WriteStartElement("frame_property");
      writer.WriteAttributeString("frameColor", "0x000000");
      writer.WriteEndElement();
      writer.WriteStartElement("properties");
      writer.WriteAttributeString("enable", "true");
      writer.WriteAttributeString("backgroundColor", "0xffffff");
      writer.WriteAttributeString("backgroundAlpha", "50");
      writer.WriteAttributeString("cssText", "a:link{text-decoration: underline;} a:hover{color:#ff0000; text-decoration: none;} a:active{color:#0000ff;text-decoration: none;} .blue {color:#0000ff; font-size:15px; font-style:italic; text-decoration: underline;} .body{color:#ff5500;font-size:20px;}");
      writer.WriteAttributeString("align", "bottom");
      writer.WriteEndElement();
      writer.WriteEndElement();
      writer.WriteStartElement("thumbnail");
      writer.WriteStartElement("basic_property");
      writer.WriteAttributeString("backgroundColor", "0x3c3c3c");
      writer.WriteAttributeString("buttonColor", "0x000000");
      writer.WriteAttributeString("borderColor", "0xb3b3b3");
      writer.WriteEndElement();
      writer.WriteEndElement();
      writer.WriteEndElement();
      int intCount = gs.allQiYeFCInfo().Tables[0].Rows.Count;
      string strOldImg;
      string strNewImg;
      string strTitle;
      string strFCXxms;
      if (intCount == 0)
      {
        qiyeyuangong.Visible = false;
      }
      if (intCount > 0)
      {
        writer.WriteStartElement("album");
        for (int i = 0; i < intCount; i++)
        {
          strOldImg = gs.allQiYeFCInfo().Tables[0].Rows[i]["fcimagepath"].ToString().Replace("~/", "");
          strNewImg = gs.allQiYeFCInfo().Tables[0].Rows[i]["fcnewimage"].ToString().Replace("~/", "");
          strTitle = gs.allQiYeFCInfo().Tables[0].Rows[i]["fctitle"].ToString();
          strFCXxms = gs.allQiYeFCInfo().Tables[0].Rows[i]["fcxxms"].ToString();
          writer.WriteStartElement("slide");
          writer.WriteAttributeString("jpegURL", strNewImg);//小图片地址
          writer.WriteAttributeString("d_URL", strOldImg);//大图片地址
          writer.WriteAttributeString("transition", "0");
          writer.WriteAttributeString("panzoom", "1");
          writer.WriteAttributeString("URLTarget", "0");
          writer.WriteAttributeString("phototime", "5");//定义图片切换的速度,数字越大,切换速度越慢
          writer.WriteAttributeString("url", "");
          writer.WriteAttributeString("title", "Xxjpm2C000801_20080809_MVPFN1A001");
          writer.WriteAttributeString("width", "710");
          writer.WriteAttributeString("height", "625");
          writer.WriteCData("&nbsp;&nbsp;&nbsp;&nbsp;【" + strTitle + "】" + strFCXxms);//显示每张图片的说明信息
          writer.WriteEndElement();
        }
        writer.WriteEndElement();
      }
      writer.WriteEndElement();
      writer.WriteEndDocument();
      writer.Close();
    }
}

效果如下图所示:

asp.net+xml+flash实现的图片展示效果示例

更多关于asp.net相关内容感兴趣的读者可查看本站专题:《asp.net操作json技巧总结》、《asp.net字符串操作技巧汇总》、《asp.net操作XML技巧总结》、《asp.net文件操作技巧汇总》、《asp.net ajax技巧总结专题》及《asp.net缓存操作技巧总结》。

希望本文所述对大家asp.net程序设计有所帮助。

广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!

RTX 5090要首发 性能要翻倍!三星展示GDDR7显存

三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。

首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。

据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。