Since I have promised to share a PureMVC site template a long time ago, and it is still bound to happen, I will now share another project I also built using the aforesaid framework.
This little project was built about four months ago, to solve a skill test for a Senior Flash Developer position in a London based agency. It took around 10 hours to complete during after-work time. A working demonstration is available here: http://demo.joaopescada.com/searchable-image-gallery/ .
The test required to develop a small image gallery in Actionscript 3 storing the images set in an XML file and allowing a tag based search functionality. Also, all coding should follow Object Oriented Programming through classes and Actionscript’s coding conventions and best practices .
The visual side of the application was also important. And, in my opinion, this is a point that marks a great difference between “hardcore” developers — with strong technical skills but, usually, low sensibility to visual design – and front-end developers in general, where a Flash Developer should be included. Any good front-end developer should comfortably know the elements and principles of design .
Take time defining the problem, and then solve it fast.
Having recently learned how to use PureMVC, this test seemed like a great way to strengthen my experience with the framework. It was fairly simple and only had to implement a couple of basic actions: show the photos with or without a tag filter applied and show each photo in detail.
For the visual layout, I opted for a grid-less structure simulating a real life environment: a wood floor with the photos scattered all over. It wasn’t the most common solution, but it was still easy to use and hopefully eye-candy enough to stand out from the crowd (the other developers applying for the same position).
As any regular MVC
project, the classes needed to be grouped in three folders / packages:
(storing all the data that the app will need),
(where anything-visual is kept and the user actions are captured) and
(providing communication between
The stage was created in a single Flash file using the
class as the document class, with all the visual assets in the library being linked to classes in the
Gluing it all together.
From this point on, you should have the source code nearby in order to check it as I briefly explain the logic behind it. The source code is available to browse and download at my GitHub repository: https://github.com/jpescada/PureMVC-AS3-Searchable-Image-Gallery .
Startup and the Controller.
It all starts in the
class in the
package. As soon as the stage is available, the
singleton is fired, initialising the PureMVC framework, overriding the
method — to allow debug control, by tracing the notification arguments — and registering the possible controller command calls with specific notifications:
is triggered by the
notification. It registers and initialises the data sources available (
), and the
(attaching it to the stage) and then requests a new photo search, without any filter applied, to populate the initial layout.
will listen for
notifications, handling all searches, through the
will respond to
notifications, setting the app state using the
, and showing or hiding the detail of a photo.
allows access to the app stage, and dispatches notifications every time the stage is resized.
works as a central point to store information about the current state of the app. Namely the current photo selected, if any, and dispatches notification when the state is changed.
loads and provides methods to access the information stored in the XML, like
and returns the result coupled to a
And the View.
registers mediators for the visual components of the layout: the
movieclip on the stage, that will load and display the photo thumbnails. It subscribes to
notifications in order to update the
movieclip as needed. It also listens for clicks in the photo thumbnails and dispatches notifications to the
when it happens.
holds a reference to the
movieclip on the stage. It subscribes to
notifications and dispatches a
notification when the user submits the search.
is linked to the
movieclip on the stage, updating the display when the subscribed notifications
are received, and dispatches a
notification when the user clicks on the
All the visual components in the library linked to classes in the
package have simple methods to update the display or dispatch custom events that will then be picked up by the associated mediators and processed as need be.
This was an overview of the logic behind the app.
Feel free to browse and change the code to see what happens and learn with it.
If you end up facing problems or doubts, just drop me an email or comment using the form bellow and I will happily give you all the help needed.
Again, the source code is available here:
and the working demo here:
Thanks for reading this article!