tags:

views:

7184

answers:

5

How to display a flash (.swf) file into asp.net ?

+2  A: 

got this from YouTube

<object width="425" height="344">
    <param name="movie" value="http://www.youtube.com/v/Xt5t9BO6xkA&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;
    <param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param>
    <embed src="http://www.youtube.com/v/Xt5t9BO6xkA&amp;hl=en&amp;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>
roman m
wow, this sure looks ugly in IE8
roman m
+1  A: 

See: Best way to embed flash in html.

strager
+1  A: 

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&amp;hl=en&amp;fs=1"&gt;&lt;/param&gt;&lt;param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/IZKl4nA5cmM&amp;hl=en&amp;fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="425" height="344"></embed></object>
Bill
+2  A: 

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:

  • it's very simple: just use flashembed("flash10", "/swf/flash10.swf") for example, if you don't need anything special you don't have to study much.
  • there a lots of demos on the site how to configure the tool
  • jQuery support: flashembed is designed for for scripters in mind with polished programming API together with a support for jQuery selectors.
  • JSON configuration: when supplying configuration for Flash objects the values can be complex JavaScript objects with arrays, strings, functions and other objects.
  • Size: the plugin weights around 5 kb when minified.

If you like you could write an ASP.NET server control, which renders the HTML you'll need on that page:

  1. Includes external script resource link using ScriptManager.RegisterScriptResource(...) (once per page)
  2. Render the flashebmed script using ScriptManager.RegisterClientScript(...) (for ever y flash you want to embed on a page)
  3. Write some useful properties like src, name etc.

Then, use the control in your pages this way for example:

<myControls:FlashEmbed runat="server" id="Flash1" Name="Clock" Src="/swf/clock.swf" />
splattne
A: 

Use the SWF object javascript helper http://code.google.com/p/swfobject/

  • it is industry standard
  • it hide the differences of flash initializations between browsers
  • it allows you to specify flash variables in browser independed way
  • it allows you to specify required version of the flash player

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>
se_pavel