Saturday, October 10, 2009

Simple way of using Flash file in ASP.Net web application

You can easily use flash movie file in our asp.net web application. For this purpose I am using FlashControl.dll which is downloadable from here. Download free version. It works fine.

First, you have to add this control to visual studio 2008 toolbox. To do this, put FlashControl.dll file to folder of your choice. I am kept it to C:\Program Files\Microsoft ASP.NET\. Now in Visual Studio, open the Toolbox window, right-click on a tab. Select “Add Tab” option. Name it “Flash” and click ok to add new tab named “Flash”. Now right-click on “Flash” tab and select "Choose items..." option. Choose Toolbox Items dialog box opens. On the ".Net Framework components" tab click "Browse..." and select the "FlashControl.dll" file from the location you kept it. I this case it is C:\Program Files\Microsoft ASP.NET\. Check that flash control is added in the list and is selected. Click OK button to add it to toolbox.

Now take a new website project. Open your default.aspx file. Now drag and drop it on your page and set MovieUrl properties to your .swf file path. In this case MovieUrl= "~/Movie/8311.swf". Optionally you can set height and width. Note that in your source page added two tags:

<%@ Register Assembly="FlashControl" Namespace="Bewise.Web.UI.WebControls" TagPrefix="Bewise" %>

<Bewise:FlashControl ID="FlashControl1" runat="server" MovieUrl="~/Movie/8311.swf" Height="223px" Width="363px" Loop="True" />

If you don't want to have FlashControl in Visual Studio Toolbox, you can do this way:

Add a reference to FlashControl.dll in your web project, then cut and paste the following code in the source view of your aspx page:

<%@ Register Assembly="FlashControl" Namespace="Bewise.Web.UI.WebControls" TagPrefix="Bewise" %>

<Bewise:FlashControl ID="FlashControl1" runat="server" MovieUrl="~/Movie/8311.swf" Height="223px" Width="363px" Loop="True" />

You can change any FlashControl’s properties (Height, Width, Menu, Loop, Scale ...) in the designer view, by using the Smart Tag or in the Properties Window.

Now run your application to enjoy flash movie on you ASP.Net web applicat