Google Analytics in Actionscript 3 classes, solved!

Disclaimer: I taught myself to program without the aid of formal instruction, and am therefore a bit rough on some basic terminology, amongst other things. While the solution below works, if anyone knows of a better way to accomplish this, I’d love to know of it.

I’m working on an update to the video player at work. One of the requested features is the ability to track viewing data in Google Analytics. I created a functional proof of concept last October that involved a call to a javascript file linked to the page. This was recently re-visited as part of a larger site re-design and didn’t work, forcing me to go back to the drawing board. Turns out, Google created a Widget that will let you track Analytics Data directly through Actionscript called ‘GAforFlash.’ You can find official documentation and a download link from the following page:

GAforFlash

The proof of concept that I created according to the documentation, or more to the point, by cutting and pasting their code into a new Flash file worked perfectly. The problem, which I could not find a documented solution anywhere on the web, was how to get this to work in a class based environment. Putting the call anywhere other then the first frame, or the top level class file produced an error(#1009). After a few hours of beating my head against the wall, and a series of test environments, I decided to apply the same logic to how global variables are constructed in Flash, and came up with the following solution:

By default, all of my Actionscript 3 work starts with a central class file called “main”, which is used to call a series of starting-state classes that handle matters like global variables, directory structure, preloaders, ect…. All classes that call upon other more program-specific class files, none of which can use the Analytics or AnalyticsLibrary widgets without causing the 1009 error. So I decided to try to declare the Analytics Tracker in the main class file, and attach a reference to it for every class that needs some form of tracking data. It worked perfectly!

Documentation:

In your top level class file, import the necessary Flash files in the package declaration:

import com.google.analytics.AnalyticsTracker;
import com.google.analytics.GATracker;

Declare the tracker in the class declaration:

public static var tracker:AnalyticsTracker;

Then set up your tracker in the function declaration:

tracker = new GATracker( this, “UA-******-**”, “AS3″, false );

Now that it’s set up, in any subsequent class where you need to track analytics data, simply import the main class in your package declaration, and add ‘main.’ to the line calling the tracker. ex:

main.tracker.trackEvent(“-Video-”, “Video Player Loaded: “+Object(e).data, “Option”, 1);

Now I can track any event that I want! I just need to modify the code to include variables that track the title of the video in question!

Posted in Actionscript, Code | Leave a comment

I’m seeing things!

From the good people at Bully Entertainment right here in Baltimore.

Interactive Breakfast – Augmented Reality on an OJ carton from Bully Entertainment on Vimeo.

The only practical application of this technology that comes readily to mind is product bonus content. As it stands, using an iPad as the visual interface seems a bit cumbersome. But why let a practical discussion interfere with how cool this is!!

Posted in Interactivity, Wanderings | Leave a comment

Angry Birds!

2011 Baltimore OriolesAfter a long cold off-season, Tonight at 7:10pm in Tampa, baseball returns to Baltimore. Please don’t embarass the city again this year!

Posted in Baseball | Leave a comment

B-More Fiber

On Wednesday March 30th, Google announced that they will be implementing Google Fiber in Kansas City, Kansas. It remains to be seen if it will be implemented into Kansas City, Missouri as well. The announcement can be found here:

http://googleblog.blogspot.com/2011/03/ultra-high-speed-broadband-is-coming-to.html

During the application process, Baltimore made national news with it’s analytical data driven application, raising the hopes of a city for a modern, fiber optic internet. I’m not sure why Kansas City was chosen, I’m sure that Google has their reasons. My feelings on the matter can be best expressed by this video of highlights from this years Ravens vs. Chiefs playoff game:

 

Posted in East Fairmount | Leave a comment

AOL called from 1994, they want their pricing structure back.

In late 1995, I got my first unlimited usage internet account and never looked back. Lately, a point that underscores the arguments about Net Neutrality is that a number of services are looking into implementing a form of bandwidth usage cap. AT&T has already done this with a cap low enough to cause even the most hardcore mac fanboy to consider switching allegiences, and many other companies have either implemented some form of cap, or are considering it. Various reasons are given for why this is, and they usually center around the fact that the telecoms in question haven’t adequately upgraded their network to provide the level of service necessary to get the most out of the modern internet. So instead, they seek to limit usage. Capped or “Metered” internet will become a reality in Canada, with the CRTC moving to implement a nationwide bandwidth cap with the “option” to pay more, sometimes substantially more to increase the size of the cap.

Today, I came across something that has the look of something that floated up to the surface from 4chan: http://i.imgur.com/M3G7f.png. The example presented is completely ridiculous, wasteful and expensive, which is exactly the point. Doing this would still be cheaper and faster then what is being sold as high speed internet. You can lower the price and increase the bandwidth estimate further by doing this with a standard hard drive as opposed to a solid state, which is a top shelf quality drive used to point out just how ridiculous the price gouging is.

Makes you wonder what’s the real motive for these caps.

Posted in Net Neutrality | Leave a comment

Atlantis Tourism Board

I stumbled across this today, it’s an interesting use of simple layout to simulate an environment. Great artwork as well. I’m seeing more and more of these types of sites. The other pages on the site are worth a look as well.

http://lostworldsfairs.com/atlantis/

Posted in Interactivity, Wanderings | Leave a comment

Double-Oh-Eightball

My boss just sent me this link knowing full well that it could de-rail my productivity for the rest of the afternoon. It will, but not in the way that you would expect:

http://agent8ball.com/

What’s particularly impressive is that the game was NOT created in Flash, but HTML5. Actually, ‘HTML5′ is an oversimplification of it, but it does use HTML5 layout rules, jQuery, and a Javascript physics engine to drive the game. I only had a brief moment to check under the hood, but the documentation of the game itself gave me some degree of insight into how it was put together.

http://mozillalabs.com/gaming/2010/11/17/agent-008-ball-creating-an-html5-game/

Looks like I’ve got my work cut out for me.

Posted in Interactivity, Wanderings | Leave a comment

Flash | HTML5

I came across this in my wanderings:

http://labs.codecomputerlove.com/FlashVsHtml5/

I haven’t had the chance to experiment with HTML5, but I’ve heard plenty of buzz around it, especially being a Flash developer by trade. Aside from liking their philosophical point on the subject, the fact that they made a game of pong that crosses from a Flash Interface on the left to an HTML5 interface on the right is incredible!

Posted in Wanderings, Web Design | Leave a comment

Regarding Internet Explorer 6

There are two schools of thought regarding Internet Explorer 6, one that assumes that the user base is still large enough to justify support, and one that feels as though it has held up progress for long enough. Either way, it’s universally reviled in the design community due to the fact that it’s a lot of extra work to support an obsolete product that adds nothing to the experience, requires a series of hacks and work-arounds to make functional and standards compliant, and has been massively insecure for quite some time now.

The widespread usage of IE6 was largely a matter of timing. It was bundled with Windows XP, and was the latest and greatest web browser for several years on any major platform, ten years ago. It endures largely as a matter of inertia, after all, a substantial number of people still use Windows XP, and most IT departments aren’t overly concerned with upgrading the users browser experience, which in some cases would require a massive overhaul to their existing intranet sites. The main problem with it, from a designers perspective at least is that it doesn’t handle layout standards properly. It can understand them to the degree that it’s aware that they exist, but it has it’s own interpretation of how to handle layout. In it’s glory days, you could just design the site for IE and call it a day. Since then, a series of new browsers were created, all of which share a common set of style guidelines, and offer greater functionality, security, and stability.

With IE9 in public beta, and many of the major players on the web announcing that they will no longer support it, I can finally take a principled stand against support it, and implement a lockout script.

Regarding the Script:

The script is a PHP browser detection script that I got here that calls a javascript redirect if it detects Internet Explorer 6 or (god forbid) earlier on every page, effectively blocking access to the site. Will post code later.

Posted in Site Updates | Leave a comment

We are live!

Version 3.0 of my portfolio site has managed to escape from it’s development environment. I hope that you like what you see!

Posted in Site Updates | Leave a comment