欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

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

程序员文章站 2023-11-17 14:09:58
本文实例讲述了asp.net+xml+flash实现的图片展示效果。分享给大家供大家参考,具体如下: 第一步:首先引入命名空间:(vs08环境中) using...

本文实例讲述了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?xml_path=slides.xml" />
  <param name="quality" value="high" />
  <embed
   src="index.swf?xml_path=slides.xml"
   quality="high"
   width="710"
   height="625"
   name="tech"
   align="middle"
   wmode="transparent"
   allowscriptaccess="samedomain"
   type="application/x-shockwave-flash"
   pluginspage="http://www.macromedia.com/go/getflashplayer" /> 
  </embed>
 </object>
</div>

第三步:生成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("    【" + 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程序设计有所帮助。