- Home
- Tutorials
- Flash
- Intermediate
- Basic Activity Tracking with Flash, Actionscript 2.0 and ASP.NET 2.0

Step Two : Creating the Flash Movie to track
Now we are going to create a new flash movie with one button on it that; when clicked will send values through our class to the server so we can save them in a database. Start by creating a new Flash Movie. Name it "TrackerTest.fla" and save it in the same directory as your Project and Actionscript file and add it to the project.
- Create a button and place it directly on the stage so its on the main timeline in Frame 1 on Layer 1. Name the instance in the properties window "MyButton".
- Click on the buttons instance and press F9 to open the Actionscript Panel.
- Once the Actionscript panel is opened paste the following code into it:
import DotNetUtils;
//Button Click Event for the Click Me Button
MyButton.onPress = function() {
//instantiate your DotNetUtils Class
var util = new DotNetUtils();
//tell the object what Page on your site is handling the tracking
util.TrackingPageName = "FlashTrack.aspx";
//issue the track activity
util.TrackActivity("MyButton", "Click");
};
So lets look at this line by line to understand what is happening.
import DotNetUtils;
This is the ever important import statement that you must use when referencing an external class (.as) file. Its equivalent to C#'s using statement. It allows you to import namespaces and classes from other files or assemblies.
MyButton.onPress = function() {
//instantiate your DotNetUtils Class
var util = new DotNetUtils();
//tell the object what Page on your site is handling the tracking
util.TrackingPageName = "FlashTrack.aspx";
//issue the track activity
util.TrackActivity("MyButton", "Click");
};
This above function is the event handler for the buttons onPress event.
var util = new DotNetUtils();
This creates an instance of our DotNetUtils class named "util". Class instantiation is a fundamental practice in OOP programming.
util.TrackingPageName = "FlashTrack.aspx";
Here we supply the DotNetUtils class its only parameter. The Tracking Page Name, this tells the class what page to send the LoadVariables command too.
util.TrackActivity("MyButton", "Click");
This calls the only method of our class, TrackActivity. We pass it two parameters.
- The Object: "MyButton" (this is the instance name - makes it easy to report on)
- The Activity: "Click" (this is the event that happened when the tracking command was issued)
So, that’s it for the flash part. Once we issue that TrackActivity command the class takes over, it builds the query string from our supplied parameters and sends it off to our pre-determined tracking page. From there ASP.NET puts it into a database.
