Posts Tagged PureMVC
Using Google Analytics for Flash in conjunction with PureMVC
Posted by zedia.net in Google Analytics on January 16th, 2009
I have been playing lately with Google Analytics for Flash and since my previous attention span (I noticed than I tend to write a lot on a topic until I find something else that interest me a lot, now is Google Analytics’ turn) was spent on PureMVC, I thought it would be good too write a post about using the two of them together.
It is actually very easy to integrate them. All you have to do is dedicate a Proxy to Google Analytics. First go download Google Analytics for Flash (I’ll write a post later on how to import it because I found several ways). From there just create a Proxy for it like this:
package com.zedia.model{ import flash.display.DisplayObject; import org.puremvc.as3.interfaces.IProxy; import org.puremvc.as3.patterns.proxy.Proxy; import com.google.analytics.AnalyticsTracker; import com.google.analytics.GATracker; public class GoogleAnalyticsProxy extends Proxy implements IProxy{ public static const NAME:String = "GoogleAnalyticsProxy"; private var _tracker:AnalyticsTracker; public function GoogleAnalyticsProxy(main:DisplayObject){ super(NAME); _tracker = new GATracker( main, "UA-639032-8", "AS3", false ); _tracker.trackPageview(); } public function trackAction(action:String):void { _tracker.trackEvent( "my category", action); } public function trackLabel(action:String, label:String):void { _tracker.trackEvent( "my category", action, label); } } }
What is cool with this Proxy is that it is tied with nothing, you can just go and use it in any project and all you have to do is change the package name. Also notice that for the category argument of the trackAction and trackLabel method I used the “my category” String. I live in Montreal in Canada and we have here two official languages: French and English. I have found that putting the language as a category was a good habit, but I think it is not the case for every one, so I left it as a generic String in this example.
The next thing you have to do is to register this Proxy. The best place to do so is in the Startup Command. You do so this way:
facade.registerProxy(new GoogleAnalyticsProxy(Object(note.getBody()).main as Main));
Google Analytics for Flash require a DisplayObject as his first parameter and the Startup command usually needs a reference to the Stage to pass to the ApplicationMediator. In this case the main in the notification will serve me both as a link to the Stage and as a DisplayObject.
Now we are all set, we can call upon this Proxy from anywhere in our PureMVC application. I would suggest making a Command for just that. Here is the code you would put in your Command:
//retireve the Proxy var googleTracker:GoogleAnalyticsProxy = facade.retrieveProxy (GoogleAnalyticsProxy.NAME) as GoogleAnalyticsProxy; //Use tracking with just an Action googleTracker.trackAction("Send to Friend"); //Use tracking with Action and Label googleTracker.trackLabel("Error", "Send to Friend - Incomplete form");
Well it is that easy to integrate Google Analytics for Flash with PureMVC.
Gingerbread house builder – TELUS holiday 2008 card
Posted by zedia.net in ActionScript 3 on December 24th, 2008
Just a quick post, while it is still the time, to bring you to the Gingerbread house builder we did for TELUS. I think it is a pretty little piece of flash that is fun and will make you smile. As it is the costum with holiday cards, the deadline was really tight but I think we managed well. This small rich internet application is packed with features that if you don’t stop to look, you won’t notice.
First the send to friend option actually sends a picture of the gingerbread house you built which was very nice to program. I had to take a screenshot(bitmapData.draw) of the House MovieClip encode it in JPEG (using as3corelib) and send it to the server. Next nifty detail is the print version of the recipe which also includes a picture of your creation. It wasn’t something really complicated to do considering I mostly used the send to friend code and put it in a PrintJob. Lastly, to save the recipe to PDF, instead of simply doing a navigateToURL to the PDF location, which would have opened a new tab in the browser with the PDF in it, I used FileReference.download to pop the download window so that the file is directly downloaded.
Independently these attentions might not seem like much, but if you put it all together the user won’t notice it but he will still feel this is a better application, without knowing why. Don’t get me wrong, I’m am not saying that the TELUS holiday card is the best application out there; I am saying that paying attention to details is what makes the difference between a nice application and a great one.
In that sense, I think there are stuff we could have done better. Mostly sound wise, to emphasize the meerkat (that is the name of the current TELUS critter) sneaking to take a bite on your gingerbread house. I’m not good at all in audio and when it comes to it I need help, and sound is somewhat not needed to make a website / application functionnal and beautiful, so it is often forgotten. But I will make sure in following projects to give it the proper time.
As I always do here is a list of the libraries I used to build it:
- TweenLite
- PureMVC (didn’t think I needed it at first but used it anyway and I am glad I did because we kept adding new features)
- as3corelib (JPEG encoding)
Well that’s it, enjoy your holidays, I surely will!
My second Rich Internet Application
Posted by zedia.net in ActionScript 3 on December 1st, 2008
A month ago (October 15th 2008) was the release of Flash player 10, but it was also the week that my second rich internet application was set (a)live. I wanted to make a post about it for a long time but I had a lot going on and only just now have things slowed down. So I present you Home Depot – redefining floors. I am really proud of it and I really put a lot of energy in it. It is the legitimate big brother of the previous RIA I made Home Depot – think in colour. I had known for a little while that I would be doing a follow up application to the paint picker and I had started planning and building the application in my head. When the development began, I knew a lot of things that I would not be doing again. Some of the pitfalls that I had faced doing the first application would not show up this time; I was ready and awaiting this new challenge with the motivation to do something better.
In the first one I had jumped head first into the code because I didn’t see any reason why I would use a framework, it was ok at first, but when the codebase became more imposing, dispatching event also became very tedious. So this time around, I used the framework PureMVC and I can say it helped a lot; it helped with the events and it also helped with shaping my ideas into classes.
An other thing I did differently was that I made sure that my ActionScript classes wouldn’t have displayed text in it. I live in Montreal and we speak mostly French here but the rest of Canada speaks English. So if I start putting copy in my code, I will need to have a codebase for French and a codebase for English. That is what I had done for the first application and every time a modification had to be done I had a whole lot of files to touch. So this time around most of the text was located in an xml file which was something better.
All in all, it was a very nice project that I liked to do a lot and seeing how its little brother got rewarded last Friday (Home Depot – think in colour won a Bronze CMA award in the retailing category on November 28th 2008) I foresee a bright future for this one too.
Here is a couple more libraries I have been using for this project:
- TweenLite
- PureMVC
- SWFAddress
- SWFObject
- Alcon (for tracing SWFAddress stuff)
I have a couple of new ideas how to improve my workflow and tools for my next RIA; can’t wait to get my hands dirty!
The PureMVC presentation video is live
The presentation I did the other day is now live and I am quite happy with the results. Well I sound like a robot( I guess nobody likes hearing is own voice) and some of the technical limitations (no webcam, audio delay, not having control of my slides) have impaired my performance, but for a first public speech, I’m pretty happy with it.
Also, as a note to myself, next time I do something like this I will inform myself better on which audience I will present to; I think the audience present at the time of the conference had already a good knowledge of the PureMVC framework and my presentation might have been a bit too light. I hope it serves greater purpose as a video than as the live thing.
Here it is; I start speaking at 16:00.
Myself in the PureMVC Pirate Internet Radio Conference
That is right, in a bit more than 6 hours, if you head to this address:
http://connectpro78922856.acrobat.com/pirate/
you will see me present some of the work I did on the two Home Depot projects we had at Twist Image. I’ll mostly be exposing how using a framework like PureMVC can change how you think and develop an application or website and why we came to choose this particular framework.
I am very excited about this opportunity and I am a bit stressed out at the same time. It’s been a long time since I did a presentation ( back while I was in school) and this is a bit different since I’ll be broadcasting from my desk using a webcam; it will be weird presenting while sat down but I think I’ll do fairly good.
Lastly, I’ve been watching a lot of the TV show The Wire so I hope I don’t slip too much slang words in there.
So again if you want to watch it its tomorrow November 19th at 12h30 (3h30 PST)
Show your support for PureMVC; Donate a click!
If you use PureMVC and you like it I suggest you head to insideRIA and vote for it on this week poll. I have multiple reasons to ask you to do this.
First off I think it’s a great project and it deserves the attention. More attention means more people might start using it and might get involved which can only be good for the project.
Also, we started using PureMVC on 3 different projects (one being HomeDepot – redefining floors) and I use it in a personal project and I really like it. I developed some skills with it and if PureMVC does well, those skills are going to be more valuable. Also, the people at my jobs might not be so happy if in the near future PureMVC would just crumble (which I don’t think could happen), I would have made them invest expertise in something that would have been shortermed.
Lastly, PureMVC is one off the few framework that support both Flash or Flex based project and that is really important for me; so go ahead, give PureMVC some love.


