Difference Between Urlloader and Loader
Difference Between Urlloader and Loader
Loader is for visual content (pictures, SWFs) and URLLoader is for non-visual (text, xml, binary data).
Specifically, Loader is a Display Object, URLLoader is not.
Q1) What is the difference between an Interface and an Abstract Class
A1) An abstract class only allows other classes to inherit from it but cannot be instantiated. If you have a
set of functions that you want all of the base abstract classs subclasses to have you can use an abstract
class.
An interface is NOT a class and is a general contract on behavior/functionality. It contains NO function
code, but classes implementing an interface must implement the functions that the interface has listed
(Even if they are just empty functions). Interfaces are useful in Polymorphism (changing the type of a
class defined object at run time):
_someClass = _someClassType1(); //Implements an interface
_someClass.someFunction(HI);
_someClass = _someClassType2(); //Normally would throw an error unless they implement the same
interface
_someClass.someFunction(HI);
Q2) What is a Stack and what is a Heap? (not AS3 specific, but basic memory allocation knowledge is
good to know)
A2) The Stack is a LIFO (last in, first out) pool of memory blocks that are allocated/deallocated very
quickly. When you call a function, a block of memory is allocated for the functions local variables and
some bookkeeping data. When you return from the function, the block of memory is released back to the
stack. A Heap allocates and deallocates memory based on usage patterns and is set aside for dynamic
allocation. It is also slower.
Q3) Explain the three phases of the Flash Event Dispatcher
A3) With event propagation you have three phases of an event. Each phase represents a path or the
location of an event as it works itself through the display objects in Flash.
Capturing phase: The parent objects of the target object from which the event originated. Any propagated
event starts with the topmost parent (stage) and works down the display object hierarchy until reaching
the original target.
Target phase: The phase where the event is at the object from which the event originated (target object).
Bubbling phase: When an event bubbles it follows the reverse path of the capturing phase and works its
way back up the parent hierarchy of the target object until reaching the top-most parent or stage.
Q4) What is function Overriding and Overloading
A4) Overriding a function means you are replacing a function that the super (parent) class has declared.
So if Class A has a walk() function and Class B extends Class A and overrides the walk() function. Class
B will have a different walk() functionality (while all the other functions are still useable as normal).
Overloading a function in AS3 follows this format drawShape(color, args). The Args are any extra
variables that are passed in at run time. So in the above example ..args could be the coordinates of the
points for the shape.
Q5) What is a static function and why would you use it?
A5) Static methods cannot be overridden in subclasses (doesnt allow for polymorphism.) You would use
them to make sure subclasses dont change a functions functionality (or variables if they are also static.)
Q6) Explain the tenets of Object Oriented Programming.
A6) There are four main tenants: Abstraction, Polymorphism, Inheritance and Encapsulation (rememabe
APIE or A PIE as the acronym).
Abstraction - Focuses on the observable behavior of an object from outside of the class. Only showing
what is necessary for the class to be used and hiding the complex functionality.
Polymorphism - through an abstract class or an interface you can create classes that are also another type
of class but override functionality for its purpose. The Cat and Dog Class extend from an Animal Class
(or implements its interface) but override the talk() function to trace meow for the cat and woof for the
dog.
Inheritance - describes the process by which one object is based on the definition of another.
Encapsulation - is the hiding of internal complexity of a class. It is the internal implementation of what is
perceived outside of the class (the Abstraction).