-- Download ActionScript Interview Study Notes as PDF --
About a month ago I lost my job making Flash banner ads, so I had to get out there and look for another ActionScripting job. I updated my portfolio website, uploaded a resume to Dice.com and the calls and emails started rolling in. I decided to start studying for my job interviews, having been in many ActionScript interviews. I took some notes of the kinds of things most likely to be asked, and thought I’d share them with anyone interested in making themselves look like an ActionScript expert.
I didn’t have time to complete these notes, so there’s some buzzwords and OOP concepts missing and I wanted to write a section about coding methodologies and office tricks like XP, Agile, Scrum, standup meetings, planning poker etc. I wound up finding a job too quickly and didn’t have the need to finish this post.
Describe the event cycles for a mouse event:
(This question seems to be asked in most of the ActionScript interviews I’ve been in, so make certain you brush up on everything relating to events.)
three phases: capturing, target and bubbles. Capturing phase starts at the top-parent movieClip and moves down the display list, firing the mouse events on every clip. Then the target phase is when it fires the event on the inner-most object that was actually clicked. Bubbles then goes back up the stack, firing the mouse event again on each of the parent clips.
by default, addEventListener listens for events in the target or bubble phase. Third parameter, called “useCapture” can tell addEventListener to listen in capture phase. Doing this allows you to call stopPropagation() on the event object to stop the rest of the event phases from firing.
mouseEnabled property on movieClips allows you to turn off the event firing, if for example, you want something in the background to be clickable but it’s being covered by another clip.
Event object properties: type:String, eventPhase:uint, bubbles:Boolean (tells IF this event will bubble, not if it’s currently in that phase), cancelable:Boolean, target:Object (the actual object that was clicked, the one that fires during the target phase), currentTarget:Object (the object that is currently firing the event)
The difference between target and currentTarget is important if you are listening for a button click, for example, but there is another movieClip inside that button. If the internal movieClip is clicked, that will be the target, but if it’s clicked around the outside of the internal clip, the button will be both the target and the currentTarget. Usually you’ll use currentTarget because that’s usually the object you’re actually listening to.
addEventListner params: type:String, listener:Function, useCapture:Boolean, priority:int (priority for multiple listeners attached to same object), useWeakReference:Boolean (usually want to set this to true so garbage collection doesn’t count the function reference, so it can be cleared from memory if you forget to removeEventListener)
more info: http://www.adobe.com/devnet/actionscript/articles/event_handling_as3.html
I’ve found that whenever an interviewer wants you to code something on the whiteboard, it’s almost always a simple loop-based puzzle, like ordering items in an array, finding a duplicate item, copying an array, etc. If I had more need of studying, I would search Google for these kind of basic loop puzzles. I suspect that this is a common whiteboard exercise in a lot of different coding language interviews as well as ActionScript.
Buzzwords and OOP concepts:
(In my experience the most important things for an ActionScript interview to have a handle on are the model-view-controller architecture, the concept of encapsulation and abstraction, abstract classes and interfaces.)
Model-View-controller (MVC): view listens for model events and dispatches user events, controller listens for view events and calls methods on the model, model behaves as the central data storage so everything knows where to go to get info
encapsulation: encapsulates the internal workings, like an API or the plastic shell of a VCR
Abstraction: process of generalization - taking a concrete implementation and making it applicable to different, albeit somewhat related, types of data, like a generic database connection class that doesn’t know which database its connecting to
Abstract Class: a class that must be extended in order to be used. Provides common functionality for similar classes
cohesion: how clearly defined something is (strive for high cohesion)
coupling: how dependent a code element is on another (strive for low coupling)
inheritance: classes extending each other. Avoid this. Inflexible
composition: when one code element contains another. more flexible than inheritance. video player may contain a slider for example
aggregation: when one code element references another so the internal one has no knowledge of its ‘parent’, but fires its events and can accept method calls, and may not be destroyed when its ‘parent’ is destroyed
service delegate: a class or something used to interface with an external service, so all service calls can go through this delegate to make code more flexible
command structure: encapsulates a method call or action as an object so it can be stored, reused, undone, etc (most useful for projects requiring undo buttons)
Object Pool: an array or collection of objects that you can grab when needed and return to the pool when you’re done with them. Reduces overhead from needing to recreate the objects each time.
Singleton: If a class is only intended to be created once, add a static function getInstance(), which creates or returns an object of itself, ensuring it never gets accidentally created a second time
Polymorphism: objects of various types define a common interface or set of methods, like how + operator can be used on strings or numbers. they may do different things depending on the type, but will have same methods
Factory: creates objects without specifying the exact class of object that will be created, providing an interface/abstraction for object creation. technically a singleton is a type of factory
Decorator: allows you to add behaviors to an existing object on-the-fly; once class sort of encapsulates another, sometimes passing one class into the other’s constructor. Or conceptually it can be as simple as two different functions that both call a single function, adding their own changes to the result
Adapter or wrapper: translates one class interface into another
Composite: treating groups of objects as a single object, can be used if you find yourself doing the same operations repeatedly on similar objects