Dynamic rich media component for ASP.Net Flash, Video and Audio controls for C# and VB.Net

How To:  Set Flash Variables in ASP.NET

1.  Key Concepts

 

1.  Purpose

    ASPNetFlash Flash Variables allow you to send text, HTML markup, or other basic data into your Flash Movie quickly and easily.  In this tutorial we will be defining the variables Title and URL.  They will be injected into the Flash Movie by the WebControl, and Flash will read them and use them to display a link with the text Title directed to the URL.

2.   Usage

    There are several ways to set the Flash Variables, and they occur at different times during the WebControl's lifecycle.

i.  Set Flash Variables Statically

    You can create static Flash Variable definitions using either the Properties Panel, the Designer Smart Tags (Visual Studio 2005 users only), or by directly manipulating the ASPX tags of your WebControl instance.  In the end, all three ways generate Flash Variable tags in the source code of the ASPNetFlash WebControl.  

ii.  Set Flash Variables Programmatically

    You can add, modify or remove FlashVariables programmatically by editing the FlashVariables collection object.  If your ASPNetFlash object was named Flash1, you could set or modify a named Flash Variable using the following series of code snippets:

[C#] [Visual Basic]

 

2.  Tutorial

 

1.  Get to Hello World with "button.swf"

  1. Download the test Flash Movie: button.zip
  2. Excluding step 1, follow the steps of the "Hello World" tutorial on the Getting Started Page substituting button.zip for cube.zip, and button.swf for cube.swf

2.  Open the Flash Variables Property Editor.

  1. Open the Designer Smart Tags Property Panel by clicking on the arrow on the top right of the WebControl.  In Visual Studio 2002/2003, open the Properties Panel.
  2. Open the Flash Variables Collection Editor by either clicking on the "Set Flash Variables..." link in the Smart Tags, or on the FlashVariables Collection in the Properties Panel.

ASPNetFlash WebControl Tutorial Flash Variables Smart tags and property panel

 

3.  Define your Flash Variables.

1.  Click "Add", and enter in "Title" in the Name field and "Hello World" in the Value field.

ASPNetFlash WebControl Tutorials Flash Variables add Flash Variables to the Flash Variables Collection

2.  Click "Add", and enter in "URL" in the Name field and "http://www.aspnetflash.com" in the Value field.

ASPNetFlash WebControl Tutorials Flash Variables add Flash Variables to the Flash Variables Collection URL

 

4.  Steps 1-3 will generate the following ASPX Code.  

Optionally, you can edit this code by hand.  Create the "HTMLAlternativeTemplate" tags within the ASPNetFlash:Flash tags as shown, and place your content within them.


ASP.NET 2.0 (Visual Studio 2005)

[ASPX]

 

ASP.NET 1.x (Visual Studio 2002/2003)

[ASPX]

 

5.  Run your webpage, and you should see the following results.  Test the link and check that it loads the ASPNetFlash homepage.

ASPNetFlash WebControl Flash Variables Tutorial Browser Results