显示Flash时控制其的宽度与高度

Flash在网页显示时,如果不指定其正确的宽度或高度或是按其宽高一定的比例,会变形。

你可以从下面地址参考到怎样取得Flash的宽度或是高度一些信息。http://www.codeproject.com/KB/graphics/ReaderSWFHeader.aspx

为了更好了解,Insus.NET在下面写了一个swf类别(代码部分)

View Code
  public  Swf( int  Width,  int  Height,  int  ThumbnailSize,  string  File)
        {

            
this ._Width  =  Width;
            
this ._Height  =  Height;
            
this ._ThumbnailSize  =  ThumbnailSize;
            
this ._File  =  File;
        }

        
public   string  Player()
        {
            
int  f_Width;
            
int  f_Height;

            
if  (_ThumbnailSize  >   0 )   // 如果指定Flash缩略显示
            {
                
// 如果Flash的宽度与高度都小于指定缩略尺寸
                 if  (_Width  <  _ThumbnailSize  &&  _Height  <  _ThumbnailSize)
                {
                    f_Width 
=  _Width;  // 等于原来的宽度
                    f_Height  =  _Height; // 等于原来的高度
                }
                
// 如果宽度大于高度
                 else   if  (_Width  >  _Height)
                {
                    f_Width 
=  _ThumbnailSize;
                    f_Height 
=  _Height  *  _ThumbnailSize  /  _Height;
                }
                
// 如果高度大于宽度
                 else
                {
                    f_Width 
=  _Width  *  _ThumbnailSize  /  _Height;
                    f_Height 
=  _ThumbnailSize;
                }
            }
            
else
            {
                f_Width 
=  _Width;
                f_Height 
=  _Height;
            }

            
return   @" <object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'width= "   +  f_Width  +   "  height= "   +  f_Height  +   " > "
            
+   @"  <param name='movie' value= "   +  _File  +   " > "
            
+   @"  <param name='quality' value='high'> "
            
+   @" <embed src= "   +  _File  +   "  quality='high' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width= "   +  f_Width  +   "  height= "   +  f_Height  +   " ></embed> "
            
+   @"  </object> " ;
        }

 

xxx.aspx使用:

< asp:Literal  ID ="Literal1"  runat ="server" ></ asp:Literal >

 

xxx.aspx.cs:

View Code
  // codeproject下载的Flash类别,Insus.NET曾经修改过,改为FlashInfo,基本是一样的,只不过添加一些自己的属性。
                FlashInfo objFlashInfo  =   new  FlashInfo(Server.MapPath(file));                
                Swf objSwf 
=   new  Swf(objFlashInfo.Width, objFlashInfo.Height, 400 , file);
                
this .Literal1.Text  =  objSwf.Player();

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值