471,618 Members | 1,123 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,618 software developers and data experts.

SWF as embedded resource and .NET

I know the question of whether or not a SWF file can be read in by a
..NET application has been asked a billion times, however, what I'm
asking is whether or not it is possible (any examples? tutorials? Flash
Object COM readme?) to embed a SWF file into your VS.NET project as a
resource, and then read in the file into the Flash object much the same
way that you currently do using the LoadMovie function that takes in a
layer and a file location path.

Anyone know of a way to load a SWF that is an embedded resource and not
in the physical directory path into a .NET application?

Thanks all
-Steve

Feb 14 '06 #1
1 2872
Hi,

<ph*******@comcast.net> wrote in message
news:11**********************@g47g2000cwa.googlegr oups.com...
I know the question of whether or not a SWF file can be read in by a
.NET application has been asked a billion times, however, what I'm
asking is whether or not it is possible (any examples? tutorials? Flash
Object COM readme?) to embed a SWF file into your VS.NET project as a
resource, and then read in the file into the Flash object much the same
way that you currently do using the LoadMovie function that takes in a
layer and a file location path.

Anyone know of a way to load a SWF that is an embedded resource and not
in the physical directory path into a .NET application?


AFAIK you can insert any file as a resource, you later would have to
"de-embed" it in a temp file and feed this file to the flash player.

With the code below you check the resources for the expected name, save it
to a temp file and return the pathof the new file
Note that the original extension is also kept

static string ExtractResource( string resourceName)
{
//look for the resource name
foreach( string currentResource in
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceNames()
)
if ( currentResource.LastIndexOf( resourceName) != -1 )
{
string fqnTempFile = System.IO.Path.GetTempFileName();
string path = System.IO.Path.GetDirectoryName( fqnTempFile);
string rootName= System.IO.Path.GetFileNameWithoutExtension(
fqnTempFile);
string destFile = path + @"\" + rootName + "." +
System.IO.Path.GetExtension( currentResource);

System.IO.Stream fs =
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream(
currentResource);

byte[] buff = new byte[ fs.Length ];
fs.Read( buff, 0, (int)fs.Length);
fs.Close();

System.IO.FileStream destStream = new System.IO.FileStream ( destFile,
FileMode.Create);
destStream.Write( buff, 0, buff.Length);
destStream.Close();

return destFile;
}

throw new Exception("Resource not found : " + resourceName);

}
Feb 15 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Drew | last post: by
1 post views Thread by n! | last post: by
2 posts views Thread by Kyle Kaitan | last post: by
4 posts views Thread by Jason Pettys | last post: by
2 posts views Thread by steve | last post: by
1 post views Thread by XIAOLAOHU | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.