Twitter: Javascript function called from Flash


#1

I’m trying to share my page with twitter, making the call from flash. I have succesfully called the function that brings the pop up window. I’m using Externalinterface object(ActionScript 3).

//---- What works—//

function tweet(){ // calls a popup window with the tweet dialog. window.open( 'https://twitter.com/share?text=Some%20default%20text', 'twt', 'width=600,height=270' ); }

function getFlashMovie(movieName) {
// gets the Flash object. Method changes with user browser.

  var isIE = navigator.appName.indexOf("Microsoft") != -1;
  return (isIE) ? window[movieName] : document[movieName];
}

//---------------- What doesn’t work ----------------//

twt.ready(function (twttr) { // bind events here
	twt.events.bind('tweet', function(event) {
		// Do something there
    	alert('tweeeet !!');

             // calls the actionscript function "sendToActionscript" declared inside the Flash
             //  the function gets the parameter "tweet",
            getFlashMovie("flash").sendToActionscript('tweet');
	});
});
It should show an alert window displaying "tweeeet !!" when the user shared my page on his tweet. I have to track this because the user gets a reward when sharing the page.

#2

If you’re controlling the opening of the window, you cannot bind to the events that emit from that window. I don’t think you’ll be able to track these events using ActionScript like this. Is it possible to leave the pop-up window code to our Javascript? Otherwise, you may need to build a more robust API-based integration if this tracking is more important to you.


#3