轮换显示的flash

以下为一个用户控件:

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using System.IO;

public partial class Player : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        TextHeight = 20;
        string pics = "img/1.jpg|img/2.jpg|img/3.jpg|img/4.jpg|img/5.jpg|img/6.jpg";
        string links = "http://sports.tom.com/nba/index.html|http://sports.tom.com/beijing2008/index.html|http://l.tom.com/c/a8/xunyan/t02/a8/?http://sports.tom.com/gnzt/guozu/|http://l.tom.com/c/a8/xunyan/t02/a8/?http://sports.tom.com/yj/|http://sports.tom.com/masters-cup06/index.html";
        string texts = "NBA|奥运|国足|意甲|网球|垃圾";
        Response.Write(GetImagePlayerString(links, pics, texts));
        //Response.End();
    }

    private string _flashpath = @"img/pixviewer.swf";

    public string FlashPath
    {
        get { return _flashpath; }
        set { _flashpath = value; }
    }


    private int _focuswidth = 220;

    public int FocusWidth
    {
        get { return _focuswidth; }
        set { _focuswidth = value; }
    }

    private int _focusheight = 180;

    public int FocusHeight
    {
        get { return _focusheight; }
        set { _focusheight = value; }
    }

    private int _textheight = 0;

    public int TextHeight
    {
        get { return _textheight; }
        set { _textheight = value; }
    }

    public int SwfHeight
    {
        get { return FocusHeight + TextHeight; }
    }


    private string GetScriptString(string links,string pics,string texts)
    {
        StringBuilder sb = new System.Text.StringBuilder("<script language='javascript'> \n");
        sb.Append(" function ImageShow() { \n");
        sb.Append(GetImagePlayerString(links,pics,texts));
        sb.Append("}");
        sb.Append("</script> \n");
        return sb.ToString();
    }

    public string GetImagePlayerString(string links, string pics, string texts)
    {
        StringBuilder sb = new StringBuilder();
        sb.Append(string.Format(@"<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=""{0}""  height=""{1}"">\n", FocusWidth.ToString(), this.SwfHeight.ToString()));
        sb.Append(string.Format(@"<param name=""movie"" value=""{0}"">\n", this.FlashPath));
        sb.Append(@"<param name=""allowScriptAccess"" value=""sameDomain"">\n");
        sb.Append(@"<param name=""quality"" value=""high"">\n");
        sb.Append(@"<param name=""bgcolor"" value=""#CCCCCC"">\n");
        sb.Append(@"<param name=""menu"" value=""false"">\n");
        sb.Append(@"<param name=wmode value=""opaque"">\n");
        sb.Append(string.Format(@"<param name=""FlashVars"" value=""pics={0}&links={1}&texts={2}&borderwidth={3}&borderheight={4}&textheight={5}"">\n", pics, links, texts, FocusWidth, FocusHeight, TextHeight));
        sb.Append(string.Format(@"<embed src=""{0}"" wmode=""opaque"" FlashVars=""pics={1}&links={2}&texts={3}&borderwidth={4}&borderheight={5}&textheight={6}"" menu=""false"" bgcolor=FFFFFF quality=""high"" width='{7}' height='{8}' allowScriptAccess=""sameDomain"" type=""application/x-shockwave-flash"" pluginspage=""http://www.macromedia.com/go/getflashplayer""/>\n", FlashPath, pics, links, texts, FocusWidth, FocusHeight, TextHeight, FocusWidth, SwfHeight));
        sb.Append("</object>\n");
        return sb.ToString();
    }
}

posted on 2007-12-14 16:17  魏绰  阅读(79)  评论(0)    收藏  举报

导航