Embedding swf (Flash) file as a resource

J

JJ

How do I embed a swf (flash) file as a resource in my custom web control?

And, if thats possible, how would I access it when I am (presumably)
overriding the RenderContents method?

Thanks in advance,
JJ
 
J

JJ

These are the steps I've tried:

1. Adding the 'myFlashFile.swf" to the web control project, and setting its
property as an embedded resource;

2. Adding the following line to the AssemblyInfo.cs file:

[assembly: System.Web.UI.WebResource("MyNamespace.myFlashFile.swf",
"application/x-shockwave-flash")]

3. Accessing the WebResource URL by way of this line in the RenderContents
method:

string flashUrl = Page.ClientScript.GetWebResourceUrl(this.GetType(),
"MyNamespace.myFlashFile.swf").ToString();

A URL is produced, but one that is clearly not understood by the browser,
even though I write the url in the usual Flash Object Code.
Is it therefore possible to do this?
 
W

Walter Wang [MSFT]

Hi JJ,

I've created following test and it's working on my side:

1) ClassLibrary1.Class1:

[assembly: WebResourceAttribute("ClassLibrary1.flash1.swf",
"application/x-shockwave-flash")]

namespace ClassLibrary1
{
public class Class1 : WebControl
{
protected override void Render(HtmlTextWriter writer)
{
string template = @"<OBJECT
CLASSID='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' WIDTH='400'
HEIGHT='320'
CODEBASE='http://active.macromedia.com/flash5/cabs/swflash.cab#version=7,0,0
,0'>
<PARAM NAME=movie VALUE='{0}'>
<PARAM NAME=play VALUE=true>
<PARAM NAME=loop VALUE=false>
<PARAM NAME=wmode VALUE=transparent>
<PARAM NAME=quality VALUE=low>
<EMBED SRC='temp.swf' WIDTH=400 HEIGHT=320 quality=low loop=false
wmode=transparent TYPE='application/x-shockwave-flash'
PLUGINSPAGE='http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_
Version=ShockwaveFlash'>
</EMBED>
</OBJECT>";
writer.Write(string.Format(template,
Page.ClientScript.GetWebResourceUrl(this.GetType(),
"ClassLibrary1.flash1.swf")));
}
}
}

2) Remember to add flash1.swf into the root folder of the class library and
configure its build action as "Embedded Resource"


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,816
Latest member
SapanaCarpetStudio

Latest Threads

Top