»
S
I
D
E
B
A
R
«
Flash _trackEvent getURL
March 12th, 2010 by admin

If you try to track event using getURL and link out to another page, the following won’t work.

on (release) {
// Track with no action
getURL("javascript:pageTracker._trackEvent(event.category, event.action, event.label);");
getURL("http:www.google.com/");
}

To track a Flash object event and direct the page to a new URL, you need to use ExternalInterface, here is how you can do it:

1. give button instance a name, for instance: my_btn
2. instead of using on(release), put the function outside of the button, on the frame
3. use externalinterface class, this will make your Flash movie looks like this:

import flash.external.*;
my_btn.onClick = function() {
    ExternalInterface.call("trackEvent");
    getURL("http:www.google.com/");
}

4. on the HTML page, use the following function:

function trackEvent() {
    pageTracker._trackEvent(event.category, event.action, event.label);
}
Share and Enjoy:
  • Print
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks
  • Blogplay



Similar Posts:
Leave a Reply

Powered by WP Hashcash