|
Step-by-step
tutorial: how to use registration-free deployment on ASP.NET 2.00
web-server for SWF Scout library
You can download the source code of this example here: swfscout_registration_free_in_asp_net2.zip This example provides a sample code to demonstrate how to use SWF Scout library in ASP.NET 2 web-applications projects without registering SWFScout.dll file on the web-server (using registration-free mode, this sample is based on an example from Maze Computers ) Create a new web-site project in Visual Studio
Enter name of new web-site and click OK
Right-click on project in Solution Explorer and select "Add Reference" command in popup menu invoked:
Browse for "ASPManifestHelpers.dll" (you can find it in ZIP with sample code) and select it and click OK to add reference:
Then create folder named "SWFScout.assembly" by right-clicking on project in Solution Explorer and selecting "New Folder" command:
Type name of the folder "SWFScout.assembly" and click OK to create a folder
Now you should add the following files into created folder: SWFScoutDemo.DLL - you can find it in SWF Scout Library
installation folder To add files right-click on project in Solution Explorer and select "Add Existing Item" command:
File selection dialog will appear - select SWFScoutDemo.dll and SWFScoutDemo.assembly.manifest files (hold CTRL and click on each file to select) and click "Add" button to add files to the project Now add webapp.manifest file (you can find it in ZIP with sample code) to the project: right-click on project in Solution Explorer and select "Add Existing Item..." command: Now add webapp.manifest file to the project: right-click on project in Solution Explorer and select "Add Existing Item..." command:
File selection dialog will appear. Select webapp.manifest file and click "Add":
Start project by clicking "Start Debugging" button as shown below:
Visual Studio will suuggest to add new Web.config file. Answer Yes as shown below:
Close Internet Explorer window and switch back to Visual Studio Web.config file will appear in the list of project files: Double-click on web.config file
Visual Studio will open editor with Web.config file in it. Add the lines after <system.web> line. So you will see a code like on a screenshot below:
Now add reference to SWFScoutDemo.dll file by doing the following: right-click on project name and select "Add Reference" command in right-click menu:
Browse to the SWF Scout installation folder (typically c:\program files\Bytescout SWF Scout\ ) and select SWFScoutDemo.dll file and click "OK" button to add reference. Finally our web-site project is ready for coding SWF generation using SWF Scout library! Double click on Default.aspx.cs file in Solution Explorer:
Editor window will appear with "Default.aspx.cs"
file in it
try
{
FlashMovie
Movie = new FlashMovieClass();
Movie.InitLibrary("demo",
"demo");
Movie.BeginMovie(0,
0, 640, 480, SWFSystemCoord.sscTwips,
12, 6);
Movie.Compressed
= true;
Movie.GenerateInMemoryFile
= true;
//
set background color to white
Movie.SetBackgroundColor(255,
255, 255);
//
add font
int
Font = Movie.AddFont("Arial",
18, true, false,
false, false,
0);
//
create and place text
int
Text = Movie.AddText("Hello, World!",
0, 0, 0, 255, Font, 0, 100, 250, 160);
//
place text into current depth
Movie.PlaceText(Text,
Movie.CurrentMaxDepth);
//
fade out text
Movie.PLACE_FadeOut(0.5f);
//
add new shape
int
Shape = Movie.AddShape();
//
draw rectangle
Movie.SHAPE_Rectangle(0,
140, 150, 285);
//
set solid fill for shape
Movie.SHAPE_SetSolidColor(50,
255, 50, true, 255);
//
place shape into current depth
Movie.PlaceShape(Shape,
Movie.CurrentMaxDepth);
//
show 10 frames
Movie.ShowFrame(10);
//
end movie generation
Movie.EndMovie();
//
get size of generated in-memory SWF file
int Size = Movie.BinaryImageSize;
//
create new buffer with size equal to generated SWF file
byte[]
buffer = new byte[Size
+ 1];
//
get in-memory swf file as byte stream
Array
MemoryImage = (Array)Movie.BinaryImage;
//
copy byte stream into buffer
Array.Copy(MemoryImage,
buffer, Size);
//
clear http output
Response.Clear();
//
set the content type to SWF
Response.ContentType
= "application/x-shockwave-flash";
//
add content type header
Response.AddHeader("Content-Type",
"application/x-shockwave-flash");
//
set the content disposition
Response.AddHeader("Content-Disposition",
"inline;filename=shapes.swf");
//
write the buffer with swf file to the output
Response.BinaryWrite(buffer);
Response.End();
}
catch
(Exception ex)
{
if
(!(ex is System.Threading.ThreadAbortException))
System.Diagnostics.Debug.WriteLine(ex.Message); }
Press F5 to start web-site project and SWF file will be generated and you'll see SWF generated by your web-site project. Generated SWF document file be displayed on the web page:
|
|
|
Copyright © ByteScout, 2003-2010. Privacy Statement
Microsoft®, Windows®, Windows 2000®, Windows Server®, Windows Vista®, Internet Explorer®, .NET Framework®, ActiveX®, Visual Basic®, Visual C#®, ASP®, ASP.NET®, Excel®, PowerPoint®, are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. Adobe®, Flash® and Acrobat® are registered trademarks of Adobe Systems, Incorporated. Mozilla®, Firefox® and the Mozilla and Firefox Logos are registered trademarks of the Mozilla Foundation. Other product names or brandnames used herein are for identification purposes only and might be trademarks or registered trademarks of their respective companies. We disclaim any and all rights to those marks. |
|