将 .swf 文件显示为 ASP .Net 页面标头

发布于 2024-07-20 02:14:32 字数 376 浏览 10 评论 0原文

我有一个 ASP。 Net 2.0 网站,以 C# 2005 作为编程语言。 我使用 CSS 进行布局。 目前我使用普通/静态 .Gif 图像作为标题。 我想通过在标题中使用一些动画来增强外观。 我使用了一些 Flash 实用程序来设计我所需的动画横幅。 但由于我无法直接使用 .swf 文件,所以我将其转换为 .Gif,我可以使用和显示它。 问题是原始 .swf 文件大小约为 75 Kb,而转换后的 .Gif 文件很大(约 4.5 Mb)。 我想显示原始 .swf 文件以提高速度。

我使用 CSS 样式表来显示 .Gif 动画横幅。 我不知道如何直接使用 .Swf 文件。

请指导我。

谢谢。

拉利特·库马尔·巴里克

I have an ASP. Net 2.0 website with C# 2005 as the programming language. I am using CSS for the layout. Currently I am using a plain/static .Gif image as my header. I would like to enhance the look by using some animation in the header. I used some flash utilities to design my required animated banner. But since I was unable to use the .swf file directly I converted it to .Gif which I am able to use and display. The problem is the original .swf file was of the size around 75 Kb whereas the converted .Gif file is huge (around 4.5 Mb). I want to display the original .swf file to improve speed.

I have used the CSS stylesheet to display the .Gif animated banner. I don't know how can I use the .Swf file directly.

Kindly guide me.

Thank You.

Lalit Kumar Barik

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

素手挽清风 2024-07-27 02:14:32

我还没有这样做,但我在 CodeProject 上找到了一些示例代码。

<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="200" height="100">
    <param name="movie" value="<% =swfFileName%>" />
    <param name="quality" value="high" />
    <embed src="<% =swfFileName%>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="100"></embed>
</object>

我认为这应该可以帮助您开始使用它。 显然,您必须将 <% =swfFileName%> 替换为对要播放的 .swf 文件的引用。

I haven't done this, but I found some sample code on CodeProject.

<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="200" height="100">
    <param name="movie" value="<% =swfFileName%>" />
    <param name="quality" value="high" />
    <embed src="<% =swfFileName%>" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="200" height="100"></embed>
</object>

I think this should help you get started with it. Obviously you have to replace <% =swfFileName%> by a reference to the .swf file you want to play.

九公里浅绿 2024-07-27 02:14:32

您可以查找 SWFObject,它是嵌入 Flash 的一种非常好的标准方法... google 搜索 swfobject 这里是代码/标记...

第 1 步:使用符合标准的标记嵌入 Flash 内容和替代内容

SWFObject 的基本标记使用嵌套-objects 方法(带有专有的 Internet Explorer 条件注释),仅通过标记确保最佳的跨浏览器支持,同时符合标准并支持替代内容

SWFObject - 步骤 1

  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
    <param name="movie" value="myContent.swf" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
    <!--<![endif]-->
      <p>Alternative content</p>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>

</div>

注意:nested-objects 方法需要双重对象定义(外部对象针对 Internet Explorer,内部对象针对所有其他浏览器),因此您需要定义对象属性和嵌套 param 元素两次。

必需的属性:

* classid (outer object element only, value is always clsid:D27CDB6E-AE6D-11cf-96B8-444553540000)
* type (inner object element only, value is always application/x-shockwave-flash)
* data (inner object element only, defines the URL of a SWF)
* width (both object elements, defines the width of a SWF)
* height (both object elements, defines the height of a SWF) 

必需的 param 元素:

* movie (outer object element only, defines the URL of a SWF) 

注意:我们建议不要使用 codebase 属性来指向 Adob​​e 服务器上 Flash 插件安装程序的 URL,因为根据限制其访问当前文档域的规范,这是非法的仅有的。 我们建议使用替代内容,并传达一个微妙的信息:用户可以通过下载 Flash 插件获得更丰富的体验。
如何使用 HTML 来配置 Flash 内容?

您可以将以下常用的可选属性添加到对象元素:

* id
* name
* class
* align 

您可以使用以下可选的 Flash 特定参数元素(更多信息):

* play
* loop
* menu
* quality
* scale
* salign
* wmode
* bgcolor
* base
* swliveconnect
* flashvars
* devicefont (more info)
* allowscriptaccess (more info here and here)
* seamlesstabbing (more info)
* allowfullscreen (more info)
* allownetworking (more info) 

为什么应该使用替代内容?

object 元素允许您在其中嵌套替代内容,如果未安装或不支持 Flash,则会显示这些替代内容。 该内容也将被搜索引擎收录,使其成为创建搜索引擎友好的内容的绝佳工具。 总而言之,当您想要创建无需插件即可浏览 Web 的人可以访问的内容、创建搜索引擎友好的内容或告诉访问者他们可以通过下载 Flash 插件获得更丰富的用户体验时,您应该使用替代内容。

步骤 2:将 SWFObject JavaScript 库包含在 HTML 页面的头部

SWFObject 库由一个外部 JavaScript 文件组成。 SWFObject 将在读取后立即执行,并在 DOM 加载后立即执行所有 DOM 操作 - 对于所有支持此操作的浏览器,如 IE、Firefox、Safari 和 Opera 9+ - 或在 onload 事件后立即执行火灾:

SWFObject - 步骤 2

<script type="text/javascript" src="swfobject.js"></script>

-->

替代内容

-->

第 3 步:向 SWFObject 库注册您的 Flash 内容并告诉 SWFObject 如何处理它

首先向定义您的 Flash 内容的外部对象标记添加一个唯一的 ID。 其次添加 swfobject.registerObject 方法:

  1. 第一个参数(字符串,必需)指定标记中使用的 id。
  2. 第二个参数(字符串,必需)指定发布内容所针对的 Flash 播放器版本。 它激活 SWF 的 Flash 版本检测,以确定是否显示 Flash 内容或通过执行 DOM 操作强制替换内容。 虽然 Flash 版本号通常由 Major.minor.release.build 组成,但 SWFObject 仅查看前 3 个数字,因此“WIN 9,0,18,0”(IE) 或“Shockwave Flash 9 r18”(所有其他浏览器) ) 将翻译为“9.0.18”。 如果您只想测试主要版本,则可以省略次要版本号和版本号,例如“9”而不是“9.0.0”。
  3. 第三个参数(字符串,可选)可用于激活 Adob​​e 快速安装并指定快速安装 SWF 文件的 URL。 当所需的插件版本不可用时,快速安装会显示标准化的 Flash 插件下载对话框,而不是 Flash 内容。 默认的expressInstall.swf 文件与项目打包在一起。 它还包含相应的expressInstall.fla和AS文件(在SRC目录中),让您创建自己的自定义快速安装体验。 请注意,快速安装只会触发一次(第一次调用它时),它仅受 Win 或 Mac 平台上的 Flash Player 6.0.65 或更高版本支持,并且它需要的最小 SWF 大小为 310x137px。
  4. 第四个参数(JavaScript 函数,可选)可用于定义在嵌入 SWF 文件成功或失败时调用的回调函数(请参阅 API 文档)

    SWFObject - 步骤 3

     <脚本类型=“text/javascript”> 
        swfobject.registerObject("myId", "9.0.115", "expressInstall.swf"); 
         
    
       
      <正文> 
        
    <对象id =“myId”classid =“clsid:D27CDB6E-AE6D-11cf-96B8-444553540000”宽度=“780”高度=“420”> <对象类型=“application/x-shockwave-flash”数据=“myContent.swf”宽度=“780”高度=“420”>

    替代内容

You can look up SWFObject it is a very good standard way to embed flash... google search swfobject here is the code / markup...

STEP 1: Embed both Flash content and alternative content using standards compliant markup

SWFObject's base markup uses the nested-objects method (with proprietary Internet Explorer conditional comments) to ensure the most optimal cross-browser support by means of markup only, while being standards compliant and supporting alternative content

SWFObject - step 1

  <object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
    <param name="movie" value="myContent.swf" />
    <!--[if !IE]>-->
    <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
    <!--<![endif]-->
      <p>Alternative content</p>
    <!--[if !IE]>-->
    </object>
    <!--<![endif]-->
  </object>

</div>

NOTE: The nested-objects method requires a double object definition (the outer object targeting Internet Explorer and the inner object targeting all other browsers), so you need to define your object attributes and nested param elements twice.

Required attributes:

* classid (outer object element only, value is always clsid:D27CDB6E-AE6D-11cf-96B8-444553540000)
* type (inner object element only, value is always application/x-shockwave-flash)
* data (inner object element only, defines the URL of a SWF)
* width (both object elements, defines the width of a SWF)
* height (both object elements, defines the height of a SWF) 

Required param element:

* movie (outer object element only, defines the URL of a SWF) 

NOTE: We advise not to use the codebase attribute to point to the URL of the Flash plugin installer on Adobe's servers, because this is illegal according to the specifications which restrict its access to the domain of the current document only. We recommend the use of alternative content with a subtle message that a user can have a richer experience by downloading the Flash plugin instead.
How can you use HTML to configure your Flash content?

You can add the following often-used optional attributes to the object element:

* id
* name
* class
* align 

You can use the following optional Flash specific param elements (more info):

* play
* loop
* menu
* quality
* scale
* salign
* wmode
* bgcolor
* base
* swliveconnect
* flashvars
* devicefont (more info)
* allowscriptaccess (more info here and here)
* seamlesstabbing (more info)
* allowfullscreen (more info)
* allownetworking (more info) 

Why should you use alternative content?

The object element allows you to nest alternative content inside of it, which will be displayed if Flash is not installed or supported. This content will also be picked up by search engines, making it a great tool for creating search-engine-friendly content. Summarizing, you should use alternative content when you like to create content that is accessible for people who browse the Web without plugins, create search-engine-friendly content or tell visitors that they can have a richer user experience by downloading the Flash plug-in.

STEP 2: Include the SWFObject JavaScript library in the head of your HTML page

The SWFObject library consists of one external JavaScript file. SWFObject will be executed as soon as it is read and will perform all DOM manipulations as soon as the DOM is loaded - for all browsers that support this, like IE, Firefox, Safari and Opera 9+ - or otherwise as soon as the onload event fires:

SWFObject - step 2

<script type="text/javascript" src="swfobject.js"></script>

-->

Alternative content

-->

STEP 3: Register your Flash content with the SWFObject library and tell SWFObject what to do with it

First add a unique id to the outer object tag that defines your Flash content. Second add the swfobject.registerObject method:

  1. The first argument (String, required) specifies the id used in the markup.
  2. The second argument (String, required) specifies the Flash player version your content is published for. It activates the Flash version detection for a SWF to determine whether to show Flash content or force alternative content by doing a DOM manipulation. While Flash version numbers normally consist of major.minor.release.build, SWFObject only looks at the first 3 numbers, so both "WIN 9,0,18,0" (IE) or "Shockwave Flash 9 r18" (all other browsers) will translate to "9.0.18". If you only want to test for a major version you can omit the minor and release numbers, like "9" instead of "9.0.0".
  3. The third argument (String, optional) can be used to activate Adobe express install and specifies the URL of your express install SWF file. Express install displays a standardized Flash plugin download dialog instead of your Flash content when the required plugin version is not available. A default expressInstall.swf file is packaged with the project. It also contains the corresponding expressInstall.fla and AS files (in the SRC directory) to let you create your own custom express install experience. Please note that express install will only fire once (the first time that it is invoked), that it is only supported by Flash Player 6.0.65 or higher on Win or Mac platforms, and that it requires a minimal SWF size of 310x137px.
  4. The fourth argument (JavaScript function, optional) can be used to define a callback function that is called on both success or failure of embedding a SWF file (see API documentation)

    SWFObject - step 3

      <script type="text/javascript">
      swfobject.registerObject("myId", "9.0.115", "expressInstall.swf");
      </script>
    
    </head>
    <body>
      <div>
    
        <object id="myId" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="780" height="420">
    
          <param name="movie" value="myContent.swf" />
          <!--[if !IE]>-->
          <object type="application/x-shockwave-flash" data="myContent.swf" width="780" height="420">
          <!--<![endif]-->
            <p>Alternative content</p>
          <!--[if !IE]>-->
          </object>
          <!--<![endif]-->
        </object>
      </div>
    </body>
    

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文