Hi,
<ph*******@comc ast.net> wrote in message
news:11******** **************@ g47g2000cwa.goo glegroups.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.Reflecti on.Assembly.Get ExecutingAssemb ly().GetManifes tResourceNames( )
)
if ( currentResource .LastIndexOf( resourceName) != -1 )
{
string fqnTempFile = System.IO.Path. GetTempFileName ();
string path = System.IO.Path. GetDirectoryNam e( fqnTempFile);
string rootName= System.IO.Path. GetFileNameWith outExtension(
fqnTempFile);
string destFile = path + @"\" + rootName + "." +
System.IO.Path. GetExtension( currentResource );
System.IO.Strea m fs =
System.Reflecti on.Assembly.Get ExecutingAssemb ly().GetManifes tResourceStream (
currentResource );
byte[] buff = new byte[ fs.Length ];
fs.Read( buff, 0, (int)fs.Length) ;
fs.Close();
System.IO.FileS tream destStream = new System.IO.FileS tream ( destFile,
FileMode.Create );
destStream.Writ e( buff, 0, buff.Length);
destStream.Clos e();
return destFile;
}
throw new Exception("Reso urce not found : " + resourceName);
}