简体   繁体   English

ASP.NET:在.aspx页中调用.swf

[英]ASP.NET: Call .swf in .aspx page

I'm trying the code below but its not working.. 我正在尝试下面的代码,但无法正常工作。

<object width="425" height="344">
  <embed src="C:\Users\fortress\Desktop\AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

Also tried this. 还尝试了这个。 Not working also. 也不能正常工作。

<object width="425" height="344">
  <embed src="~/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

Problem: 问题:

  1. The swf is not displaying. 瑞士法郎未显示。
  2. I saw an error when I open the designer saying that "A control type was not specified or the specified type could not be found." 打开设计器时,我看到一个错误,说“未指定控件类型或找不到指定的类型”。 I already import the shockwave-player for flash but still this error appeared.. 我已经导入了flash的Shockwave Player,但是仍然出现此错误。
  3. I want also that the .swf will be fullscreen played in .aspx. 我还希望.swf将在.aspx中全屏播放。

I'm newbie in ASP.net.. SO yeah, please explain also the code if its okay... 我是ASP.net的新手。是的,如果还可以,还请解释代码...

Here's the output in client-side: 这是客户端的输出:

在此处输入图片说明

Here's the whole code for my client-side: 这是我客户端的完整代码:

在此处输入图片说明

Thanks! 谢谢!

This isn't ASP.NET, this is HTML. 这不是ASP.NET,而是HTML。 It might be served to the client by an ASP.NET server-side application, but that makes no difference to the client. 它可能由ASP.NET服务器端应用程序提供给客户端,但这对客户端没有影响。

As far as HTML goes, your paths are broken. 就HTML而言,您的路径已损坏。 In both cases: 在两种情况下:

  • C:\\Users\\fortress\\Desktop\\AppointmentApp.swf C:\\ Users \\ fortress \\ Desktop \\ AppointmentApp.swf
  • ~/Styles/Images/AppointmentApp.swf 〜/样式/图片/AppointmentApp.swf

In the first case you're referencing a file system path. 在第一种情况下,您要引用文件系统路径。 This wouldn't work on any client computer which doesn't have that file. 这在没有该文件的任何客户端计算机上均不起作用。 If the file is on the web server then no client will be able to access the web server's C: drive. 如果文件在Web服务器上,则没有客户端将能够访问Web服务器的C:驱动器。 In the second case you're using a server-side relative path with a ~ , and no client will be able to make sense of that. 在第二种情况下,您使用带有~的服务器端相对路径,并且没有客户端能够理解这一点。

When the page renders, the path needs to reference the file from the client's perspective. 页面呈现时,路径需要从客户端的角度引用文件。 Something like this: 像这样:

  • /Styles/Images/AppointmentApp.swf /Styles/Images/AppointmentApp.swf

Or perhaps: 也许:

  • ../../Styles/Images/AppointmentApp.swf ../../Styles/Images/AppointmentApp.swf

Or whatever the path is from the rendered page to the SWF file. 或从渲染页面到SWF文件的任何路径。

I'm not 100% sure if this works well for object / embed tags, but you might be able to use the ~ path reference if you make the tag a server-side control. 我不是100%肯定,如果这个工程很好的object / embed标签,但你也许能够使用的~如果你做的标记服务器端的控制路径参考。 That should just be as easy as adding runat="server" to the tag: 就像将runat="server"添加到标签一样简单:

<embed runat="server" src="~/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>

This would indicate to the ASP.NET application that the control needs some server-side processing before it's rendered to the client, and that processing would include evaluating relative paths. 这将向ASP.NET应用程序指示该控件在呈现给客户端之前需要进行一些服务器端处理,并且该处理将包括评估相对路径。

You need both <param> movie tag and <embed> . 您同时需要<param>电影标签和<embed> Try this: 尝试这个:

<object type="application/x-shockwave-flash" width="425" height="344">
<param name="movie" value="/Styles/Images/AppointmentApp.swf">
  <embed src="/Styles/Images/AppointmentApp.swf" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>

Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM