将 .swf 文件显示为 ASP .Net 页面标头
我有一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我还没有这样做,但我在 CodeProject 上找到了一些示例代码。
我认为这应该可以帮助您开始使用它。 显然,您必须将
<% =swfFileName%>
替换为对要播放的 .swf 文件的引用。I haven't done this, but I found some sample code on CodeProject.
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.您可以查找 SWFObject,它是嵌入 Flash 的一种非常好的标准方法... google 搜索 swfobject 这里是代码/标记...
第 1 步:使用符合标准的标记嵌入 Flash 内容和替代内容
SWFObject 的基本标记使用嵌套-objects 方法(带有专有的 Internet Explorer 条件注释),仅通过标记确保最佳的跨浏览器支持,同时符合标准并支持替代内容
SWFObject - 步骤 1
注意:nested-objects 方法需要双重对象定义(外部对象针对 Internet Explorer,内部对象针对所有其他浏览器),因此您需要定义对象属性和嵌套 param 元素两次。
必需的属性:
必需的 param 元素:
注意:我们建议不要使用 codebase 属性来指向 Adobe 服务器上 Flash 插件安装程序的 URL,因为根据限制其访问当前文档域的规范,这是非法的仅有的。 我们建议使用替代内容,并传达一个微妙的信息:用户可以通过下载 Flash 插件获得更丰富的体验。
如何使用 HTML 来配置 Flash 内容?
您可以将以下常用的可选属性添加到对象元素:
您可以使用以下可选的 Flash 特定参数元素(更多信息):
为什么应该使用替代内容?
object 元素允许您在其中嵌套替代内容,如果未安装或不支持 Flash,则会显示这些替代内容。 该内容也将被搜索引擎收录,使其成为创建搜索引擎友好的内容的绝佳工具。 总而言之,当您想要创建无需插件即可浏览 Web 的人可以访问的内容、创建搜索引擎友好的内容或告诉访问者他们可以通过下载 Flash 插件获得更丰富的用户体验时,您应该使用替代内容。
步骤 2:将 SWFObject JavaScript 库包含在 HTML 页面的头部
SWFObject 库由一个外部 JavaScript 文件组成。 SWFObject 将在读取后立即执行,并在 DOM 加载后立即执行所有 DOM 操作 - 对于所有支持此操作的浏览器,如 IE、Firefox、Safari 和 Opera 9+ - 或在 onload 事件后立即执行火灾:
SWFObject - 步骤 2
-->
替代内容
-->
第 3 步:向 SWFObject 库注册您的 Flash 内容并告诉 SWFObject 如何处理它
首先向定义您的 Flash 内容的外部对象标记添加一个唯一的 ID。 其次添加 swfobject.registerObject 方法:
第四个参数(JavaScript 函数,可选)可用于定义在嵌入 SWF 文件成功或失败时调用的回调函数(请参阅 API 文档)
SWFObject - 步骤 3
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
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:
Required param element:
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:
You can use the following optional Flash specific param elements (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
-->
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:
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