7

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

5 Answers 5

12

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>
Sign up to request clarification or add additional context in comments.

1 Comment

It's IE, what do you expect?
3

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> 

Comments

2

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" />

Comments

1

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>

Comments

1

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" />

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.