写了一个Flash WebCustomControl

       前段时间需要在Asp.net 页面中加入一个Flash,由于习惯了使用控件,想找一个用用,可惜Vs没有提供,最后决定写一个。
       到现在,写了一个最简单的,就是把显示Flash需要的HTML元素作了封装, 没有做其他处理。
下载,到:Flash WebCustomControl
      代码如下:
using System;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;
using Pierce.AttributeClass;
namespace Pierce.WebControlFlash
{
    
/// <summary>
    
/// WebControlFlash:存放Flash的控件
    
/// </summary>

    [DefaultProperty("Text"),
        ToolboxData(
"<{0}:WebControlFlash runat=server></{0}:WebControlFlash>")]
    [LastModified(
"2006-04-08","存放Flash的控件,如果override base.Width,base.Height,"+
         
"不会影响Flash的显示大小,需要重新设置width,height")]
    
public class WebControlFlash : System.Web.UI.WebControls.WebControl
    
{
        
private string width;
        
private string height;
        
private string filepath;

        
/// <summary>
        
/// 属性,读写,设置Flash的宽度
        
/// </summary>

        [Bindable(true),
            Category(
"Appearance"),
            DefaultValue(
"")]        
        
public string FlashWidth
        
{
            
get
            
{
                
return width;
            }


            
set
            
{
                width 
= value;
            }

        }

        
/// <summary>
        
/// 属性,读写,设置Flash的高度
        
/// </summary>

        [Bindable(true),
        Category(
"Appearance"),
        DefaultValue(
"")]
        
public string FlashHeight
        
{
            
get
            
{
                
return height;
            }


            
set
            
{
                height 
= value;
            }

        }

        
/// <summary>
        
/// 属性,读写,设置Flash的文件路径
        
/// </summary>

        [Bindable(true),
        Category(
"Appearance"),
        DefaultValue(
"")]
        
public string Filepath
        
{
            
get
            
{
                
return filepath;
            }


            
set
            
{
                filepath 
= value;
            }

        }


        
/// <summary>
        
/// 输出Flash,无法使用base.Width,base.Height控制Flash的宽度和高度,原因未明
        
/// </summary>
        
/// <param name="output"> 要写出到的 HTML 编写器 </param>

        [LastModified("2006-04-08","输出Flash,无法使用base.Width,base.Height控制Flash的宽度和高度,原因未明")]
        
protected override void Render(HtmlTextWriter output)
        
{
            output.Write(
string.Concat(
                
"<OBJECT style=\"WIDTH: ",
                width,
                
"px; HEIGHT: ",
                height,
                
"px\" codeBase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\"",
                "classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" VIEWASTEXT>",
                
"<PARAM NAME=\"_cx\" VALUE=\"9948\">",
                
"<PARAM NAME=\"_cy\" VALUE=\"3175\">",
                
"<PARAM NAME=\"FlashVars\" VALUE=\"\">",
                
"<PARAM NAME=\"Movie\" VALUE=\"",
                filepath,
                
"\">",
                "<PARAM NAME=\"Src\" VALUE=\"",
                filepath,
                
"\">",
                "<PARAM NAME=\"WMode\" VALUE=\"Window\">",
                
"<PARAM NAME=\"Play\" VALUE=\"-1\">",
                
"<PARAM NAME=\"Loop\" VALUE=\"-1\">",
                
"<PARAM NAME=\"Quality\" VALUE=\"High\">",
                
"<PARAM NAME=\"SAlign\" VALUE=\"\">",
                
"<PARAM NAME=\"Menu\" VALUE=\"-1\">",
                
"<PARAM NAME=\"Base\" VALUE=\"\">",
                
"<PARAM NAME=\"AllowScriptAccess\" VALUE=\"\">",
                
"<PARAM NAME=\"Scale\" VALUE=\"ShowAll\">",
                
"<PARAM NAME=\"DeviceFont\" VALUE=\"0\">",
                
"<PARAM NAME=\"EmbedMovie\" VALUE=\"0\">",
                
"<PARAM NAME=\"BGColor\" VALUE=\"\">",
                
"<PARAM NAME=\"SWRemote\" VALUE=\"\">",
                
"<PARAM NAME=\"MovieData\" VALUE=\"\">",
                
"<PARAM NAME=\"SeamlessTabbing\" VALUE=\"1\">",
                
"<PARAM NAME=\"Profile\" VALUE=\"0\">",
                
"<PARAM NAME=\"ProfileAddress\" VALUE=\"\">",
                
"<PARAM NAME=\"ProfilePort\" VALUE=\"0\">",
                
"<embed src=\"Player.swf\" FlashVars=\"\" quality=\"high\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\"",
                "\"type=\"application/x-shockwave-flash\" width=\"550\" height=\"400\"> </embed>",
                @"</OBJECT>"));
        }

    }

}

posted on 2006-04-08 13:03  Pierce  阅读(894)  评论(0)    收藏  举报

导航