How to display a flash (.swf) file into asp.net ?
The embed is handled via what you output in HTML -- there's nothing specific about it ASP.NET.
Put another way, the same way you output any other HTML <B>, <I>
, etc., you can output something like:
<object width="425" height="344"><param name="movie" value="http://www.youtube.com/v/IZKl4nA5cmM&hl=en&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/IZKl4nA5cmM&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
Using HTML5 embed tag alone would do the trick in all modern browsers.
<embed src="FILE" type="application/x-shockwave-flash" width="X" height="Y" />
got this from YouTube
<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/Xt5t9BO6xkA&hl=en&fs=1"></param>
<param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/Xt5t9BO6xkA&hl=en&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed>
</object>
You'd only need this:
<object width="425" height="344">
<embed src="PATH_TO_YOUR_FILE" type="application/x-shockwave-flash" width="425" height="344"></embed>
</object>
Use the SWF object javascript helper http://code.google.com/p/swfobject/
See example below
<script type="text/javascript">
var flashvars = {
playlistURL: "playlist.xml",
skinURL: "skin-transp-grey.swf",
width: "400",
height: "300",
continuous : "true"
};
var params = {
allowscriptaccess: "always",
allowfullscreen: "true",
};
var attributes = {
id: "mediaplayer1",
name: "mediaplayer1"
};
swfobject.embedSWF("mediaplayer.swf", "video", "400", "300", "9.0.0", "expressInstall.swf", flashvars, params,attributes);
</script>
I would consider using FlashEmbed, a JavaScript tool that you can use to embed Flash objects to you website.
It is simple to use and has many advantages:
flashembed("flash10", "/swf/flash10.swf")
for example, if you don't need anything special you don't have to study much.If you like you could write an ASP.NET server control, which renders the HTML you'll need on that page:
ScriptManager.RegisterScriptResource(...)
(once per page)ScriptManager.RegisterClientScript(...)
(for ever y flash you want to embed on a page) Then, use the control in your pages this way for example:
<myControls:FlashEmbed runat="server" id="Flash1" Name="Clock" Src="/swf/clock.swf" />