为了账号安全,请及时绑定邮箱和手机立即绑定

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

标签:
JavaScript

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 class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original=" + _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();

 

 

 

点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消