ColdFusion in Baltimore Rotating Header Image

Tracking Flash movie views with JavaScript and ActionScript

So, you have an embedded Flash video on your page that has a “play” button,  and you want to silently track the number of  “plays”, and do it with the same web statistics program you use for all your other pages? Well, here’s how you do it in ActionScript 3 and JavaScript.

1- Add the following ActionScript into your Flash file’s 2nd frame, or a frame in the timeline where you know it began playing or has played, such as the last frame.

import flash.external.ExternalInterface;“frameNone”);

This step calls the external Javascript function.

2- Create a blank page called flashmovie.html in the same directory as the page with the Flash movie. This is the page you will track as the number of “plays” since it will only load when users play the video. You can also add your own code to this page to call external web site statistics programs such as Hitslink, that you would normally do with any other page.

3- Add this JavaScript inside the <head></head> tags of the page where the Flash is embedded.

<script type=”text/javascript”>

//for flash intro
function frameNone(){
<iframe src=”” id=”flashFrame” style=”visibility:hidden”></iframe>
This step loads the blank page from step 2 into an invisible IFRAME on the same page as the Flash movie.
Now you have page that was hit when the movie got played and it’s logged with your webserver.
That’s all folks!

Comments are closed.