Skip to content
February 6, 2013 / Danii Oliver

Naming multiple instances and arguments in For Loop

This is the syntax for when you want to tell multiple instances to do the same thing but you don’t want to have to type the commands one by one.
With this setup you can just tell it once all you want it to do then stick in a for loop and it will run as many times as there are instances named and specified

for(var i:uint=0;i<4;i++){

In Robotlegs if you are building a Flash Professional your syntax will be a bit different.
For instance if the items you are trying to target are within an Injected class you must create your naming string first and replace “this’ with the [Inject] public var name then the created string inside the brackets not concatenation  It will be more like you a writing in the form of KEY[VALUE].property = or KEY[VALUE].method().

var table:String;
var hover:String;

for (var i:uint = 0; i < 5; i++)
table = “table” + i;
hover = “coverHover” + i
view[table].buttonMode = true;
view[table].addEventListener( MouseEvent.MOUSE_DOWN, liftCover, false, 0, true );

view[hover].visible = false;
view[table].addEventListener( MouseEvent.MOUSE_OVER, hoverCover, false, 0, true );
view[table].addEventListener( MouseEvent.MOUSE_OUT, offCover, false, 0, true );

June 11, 2013 / Danii Oliver

Video Streaming Content Protection – FMS

FMS – Flash Media Server Allows for the protection of media content in different ways.

What this means is that content will be secure from caching on users computer, time limits on playback.

Setup is as follows:

All media needs to be added to the FMS applications/vod/media directory
All manifests need to me added to the webroot/vod directory

If RTMP Protected Streaming
to play the FLV files and have them stream the FLVs need a link like this:

to play the F4V files and have them stream the F4Vs need a link like this:

For Dynamic Bitrate
use the manifest files in the url

If HDS or httpDynamicStreaming (Open Source never blocked)
((this is for live video fragmenting))
9(this is the streaming path)0

If these methods are not possible they may use

March 20, 2013 / Danii Oliver

Constructor – Object Oriented Analysis and Design


Constructors initialize. You can have more than one constructor this is overloading the constructor.
class Inkjet {
public Inkjet(){…}

public Inkjet(int red, int blue, int green){…}

*with signatures the name of the arg fields is not important it is the type and order

If constructor is public…
Inkjet p = new Inkjet(); ← constructor must be public for this to work

If constructor is private, you can not instantiate the class from outside the class.
The class can only instantiate itself! → [see static Methods to make sense of this]

If the constructor is protected it means that it is expected to be instantiated in the subclass.

March 18, 2013 / Danii Oliver

Overriding – Object Oriented Analysis and Design


Overriding Purpose to redefine a method that is in the superclass in order to have the subclass version be the one that runs.

  • Can only override public and protected.
  • CAN NOT be private, the subclass will not see it.
  • Return type must match and so must the signature.

If class Printer has a method Print(), the class Inkjet can’t output a better version of Print() if it is using the superclass defined Print() method.

If you want to make the Print() method better or different you would define your own Print() method in class Inkjet.
! →  Simply creating another method named print inside class Inkjet then creating an object pointer /reference Printer p = new Inkjet() then calling p.print(); will still call the class Printer’s Print() method.

class Output {

public doPrint(Printer p){

p.Print(); ← this does not happen by default to be the object type


*this is good because you will never have to change this code for any subclass of printer used

But if you override the Print() method in Inkjet and you point to an Inkjet
Class Printer {
public void print(){…}

Class Inkjet: Printer{
override public public void print(){…}
**Polymorphism will work in your favor here if you want the method in the subclass

How to get the method of the subclass?

Override – tells the compiler don’t pay attention to the type of reference PAY ATTENTION to the type of object!

  • Overriding needs two classes the Superclass and a Subclass.
  • The signatures need to be the same – name, arguments and return type.

**You can not override a PRIVATE method.
Overriding protected can only be used inside subclass. You cannot call a protected method in the outside class that instantiates an object of the subclass

The value of overriding is that you will be able to call the method of a subclass over the same method of it’s superclass

  • You want to do this if you are enhancing or changing the functionality of a subclass’s method.
  • Redefine = Override

Enhancing not Changing with private fields

If you want to call the parent method and improve it you would call the super.Method
or base.Method

class Inkjet {
public void Print{



*Super means you don’t have to rewrite the original code that you still need.
*Here you are only calling one public or protected method from inside a superclass.


public virtual void Print() {…} → Flags the superclass method to be possibly overridden. You don’t have to override but you can if you want to. You must use the virtual keyword for Polymorphism to work.

March 14, 2013 / Danii Oliver

Overloading – Object Oriented Analysis and Design


Signature of a method is the name of the method plus the order and type of the arguments.

  • return type is not a signature.
  • with signatures the name of the arg fields is not important it is the type and order.
  • overloading is just reusing the name and changing the args for a unique signature.
  • order and type have to be different
  • does not take return type into consideration. If the return types are different… you will get a compiler error

Class A {
public void foo(int a){…}

public void foo(char b){…}

public void foo(int a, char b){…}

public void foo(char b, int a){…}

public void foo(string b, string a){…}

This is syntactical sugar! It doesn’t improve anything about the program all it does is allow the programmer to not have to remember another method name, all they have to do is set the arguments she wants to set.

*Overloading can only happen inside a class. Feature point the order and type of the arguments must differ for each method.

Have to be in place :

  • must be within one class
  • keep name change order and type of arguments
  • has nothing to do with return types

“Superclass Methods” can be overloaded within a Subclass

Class Printer {
public string print(int x){…}

Class Laser : Printer{
→ STILL HAS ← public string print(int x){…}
public string print(char y){…}

++Overloading and Overloading are NOT related

+++This is not possible in AS3.

March 7, 2013 / Danii Oliver

Encapsulation & Access Level Controls

Discussion topics:

Private vs Protected vs Public & Constructors


  1. Encapsulation hides or protects data declared and implemented within a function

void foo(){

int x;


int Incr(int a){

int x;



Encapsulation puts a brick wall around whatever it is doing.

All things in a Class once declared can’t be accessed unless it’s inside the Class itself. Encapsulation happens to a Class by default.

**members or fields of a Class are private by default.

class Student {

private string name;

public int age;

//get/set methods


Student s = new Student(); = “John”; → complier error

s.age = -20; → no error b/c it is open to altering

**With Dynmaic memory allocation: From “” the [.] is a member selector. Before the [.] is a reference to the object. After the [.] is the member of the object.

Stack: memory allocated at the beginning for any variable declaration – Compile Time

Heap: memory allocated later at runtime when the key word “new” is used. Can also destroy when no longer needed in some languages. not Java – Runtime

**You need to return memory to the Heap if not being used. You don’t want to run out and crash your program.


  1. to Instantiate : means to go and get memory for something. The something has to know where the memory is that is the purpose of the variable used.


  1. Access Specifier. It qualifies the declaration of a var or method to be private and thus inaccessible by anything outside of the class. Private is default in a Class and default within the scope of a method a variable or method is declared in.
  2. Make methods private when it is part of the creation/definition of a Class’s default actions.


  1. The complete opposite of private. Anyone who has access to an object can set values on member field or data. Public methods can also be called externally. Yes you can make fields public but DON’T
  2. Only const can be public because they can’t be changed anyway.
  3. Make methods public if the method is an action that needs to be called later by another class to complete a requirement.

class Printer {

public void Print()


// print functionality


class Student (){

Print p = new Printer();

p.Print() → no error b/c it is open to be called to execute


**the print method HAS to be public because it will never be called within itself.

***The responsibility of your Class should be to do one thing.

**Association needs to have method calling!


  1. Balance between Private and Public
  2. Protected means it can only be accessed by a subclass.
  3. A subclass does not have access to private members of its superclass. Everyone has access to all public…but…
  4. Protected means only the subclass that extends a superclass has the ability to have access to members it would need and no other class may edit.

public class Rectangle {

protected int side;


public class Square:Rectangle {

public int Area(){

return side*side



class Student (){

Rect r = new Rect();

r.side = 10 → compiler error

Square s = new Square();

s.side = 15; → compiler error



  1. Less strict than private. It allows package access. in the same folder and more framework based.


– private

+ public



public class Rectangle {

protected int _side;


public class Square:Rectangle {

public int Area(){

return side*side


public int getSide(){

return _side;


public void setSide(int side){

/*here you can check for meeting

requirements i.e*/

if(side >=0){

this.side = side; //if _ not used SAFER

_side = side; //if declared with _




class Student (){

Square s = new Square();

s.setSide( 15 ); → no error b/c a public method was called to setSide


*the keyword [this] is a self reference.

left of assignment with this is declaration inside the class

right of assignment is the var coming in to be set.

*using [this] prevents errors later. This is Defensive programming

**the leading _ is another way of visualizing this if it was declared as such. _ is a coding standard it helps to see the scope.

only getter = read only

only setter = write only

* PUBLIC fields and methods can be accessed anywhere.

* PRIVATE fields and methods can only be accessed ONLY from within the class that declared or defined them. i.e these fields and methods can only be activated by the class’s normal functionality or via setting from getter/setter or a constructor.

Developer thinks to solve a problem

Architect realizes there are two problems : its not simply the solution for ABC but you also need a framework that will allow you to leverage that solution elsewhere in the future. “The class you make today could be a superclass in the future”. You can’t make one big class that does everything. It needs to be able to be inherited. The should be lean as you would inherit something that has 15 fields and 50 methods.

** PROTECTED is used for when you foresee a superclass forming and you know you want subclasses to be able to have access.

PUBLIC, PRIVATE & PROTECTED have no meaning inside the class that it’s defined. Once outside or instantiating an object then it make all the difference.

Subclass get private fields and methods (or members) from it’s superclass. While the subclass gets the information, it does not have access to change any of those private members. Inheritance is all or nothing period.


  1. Constructors don’t construct they initialize. A programmer would initialize like this int x=0;
  2. Variable is not initialized by default in every language, some set string to =“ ” or int to 0 but another may not thus making int = NaN;

Why not initialize a user defined Type? You don’t want to set a member after you may get errors.

  1. The constructor initializes before the first use. You want the constructor to be complete before student s = new Student(); is complete.
  2. The constructor can only initialize based on the types of fields in the class => this is a default constructor.

Options: Make your own constructor…

Make a Constructor

  1. The constructor has the name of your Class. The name of the constructor is the name of the Class. It does not need a return type. Thus public Student(){}
  2. new” in the class making an object of another Class is what initializes the fields. it will be set by passing data or by code defined in the constructor
  3. The constructor is inside of the Classes self. Once the Class is instantiated it has been constructed and initialized properly.
  4. Constructor with no arguments is a Default Constructor. If the compiler has to make it it will have no arguments
  5. The constructor is there to preserve your RULES. Use it well.

External set: nothing is hard coded

Set @ Instantiation

class Student {



public Student(string:fname, string:lname) {

this.fname = fname;

this.lname = lname;



class College (){

Student s = new Student(“Joe”, “Smith”);

string a = s.GetFname();

Student t = new Student(“Bill”,”Withers”);

string b = t.GetFname();


Self setroom for problem or the need to reset every instance


class Student {



public Student() {

fname = Joe;

lname = Smith;

→ problematic b/c every instance is set to these values which may be inappropriate



class College (){

Student s = new Student();

string a = s.GetFname();

Student t = new Student();

string b = t.GetFname();



February 27, 2013 / Danii Oliver

Classes – Object Oriented Analysis and Design

pt 2


How to get from Class to Object?
How to go from knowing you need a Class to making a Class?
How to capture the HAS part the relationship? (have, has, is, associated with)

Modules – you can edit and make changes without messing up the other things.

Class – means I have something in my program that represents the real world
a class is a set = like a car is a class not all are the same but it would be the basis of all “cars”
a class is a generalization. it does not describe one object it describes all cars, no specifics.
five wheels, one for steering, at least one door and engine and a gas tank. No kinds.
a car class would also have methods that all cars should do (i.e. drive, reverse, stop, brake)
Class name Student
first name last name, user id,

Fields – are the line items that would be generalizations
Class =
Blueprint of an object
Type : can declare variables the name of the type is the name of the class [var s:Student = new Student(); ]

Type: defining what kind of stuff can get stored at a memory location
Class = Abstract or User Defined } DataType
user defined because you make it up.
typing checking make

Student s; //C++ => object
Student t; //C#, vb.Net, Java, etc => a reference (not yet an object) they need to be instantiated.

Primitive types int, char/string, float/number, bool/boolean

All of the above is part of Design time when you build your class.

At runtime you will use the class. The blueprint is the class specifications to use it you will use the Object.

How to get from Class to Object?
Instantiation = to get the memory and return the address of the memory. This memory will make up the object like matter.

-The compiler know how much memory you need based on the primitive type fields and methods designed in the class.

-The object is empty of values but not empty of available memory for the one object.

Stack vs Heap = The stack is where memory for local vars or functions come from. The Heap is extra memory that is dynamically allocated to a “new” instantiation of an object.
C++ = Stack
All Others = Heap
declaring without new is the placeholder for the address but not the actual object. just declaring uses less memory until you instantiate it.

How to go from knowing you need a Class
to making a Class?

First remember to start with generalizations.
(Yes this begins with good requirements and to get good requirements you should first ask for or define use-cases =context for the requirements in the way they will be used instead of just because which might be out of order )

If you say we are going to have these kind of roles or different kinds of people the initial thing would be a class…. Role, People Cars these are classes.

Class = noun
Method = verb

All nouns in your requirements are potential classes
All verbs in your requirements are potential methods

*any function written must live in a class no more global functions they will be in a calls which makes it a method

*no variables will be global they must all be in a class making it a field

Look at your requirements / use case underline all nouns and circle all verbs.

A bank has customers. Each customer has an account

3 potential classes = bank, customer, account
now validate => CRC
Class Responsibility Collaborators
Name? Why? With which objects will objects of this class interact ?

Bank –
Why = the bank represents a real bank that would have customers and accounts
Who would it interact with = Objects of Account and Customers

This process is Iterative , you may have to go further down the list to learn who it will collaborate with.

Bank has to see account and customer
Customer needs to go to bank to see account
account need to know bank and customer

Iterative process is going back to see if each time you look at a class will it change when considering other objects. When nothing changes anymore, then you stop. This may take a number of times to look at, write down soon you will draw UML

You must justify if something should be a class in your program, it must solve a problem in the program. Every Class should not do the same thing. One Class does all it needs multiple should do the same thing. They should have one responsibility. You should understand why is it is there, if you can’t answer during design you can’t answer during runtime.

OOP is to translate our thinking to development. Behaviors and Data Points all stay together. Real world things also hav relationship. Objects and Class and relationships. HAS = means there is a relationship.

How to capture the HAS part the relationship?
(have, has, is, associated with)

Next Step realize that all relationships are not the same. There are requirements then there are nice to haves. This relationship will definitely help define what is needed in the class.

So far nothing connecting these three. There is not collaboration. If there are no connections then the requirement
A bank has customers. Each customer has an account
can’t be met.
Right now we see that there are three class that have nothing to do with each other nor any objects. You can’t acquire a relationship at runtime it must be done in the design.


Inheritance is the only relationship the compiler will help you with.
**In a NON OOP environment you must start over each time, copy and paste the class then add to it. You can’t extend the generic verision in procedural because there is no way to make a relationship.

Inheritance resembles the real life relationship of inheriting all traits of a parent. The Class A can and will be a part of Class B. To understand if the is an Inheritance relationship add IS-A between the two classes
pruis is-a car -YES
car is-a pruis – NO

dog is-a animal – YES
bird is-a animal
pig is-a animal
*there will be some of the same field and some of the same methods.
legs, fur, make sounds,
* All of the things on the right needs to be true for the left

dog is-a cat -NO

bank is-a customer? NO
customer is-a bank? Not in this program
*We are trying to find if there is a similarity to form a relationship that would be based on Inheritance
* All of the things on the right needs to be true for the left

Inheritance is an all or nothing thing!!! If its not all true Inheritance is not appropriate or your Class A is not generic enough.

In UML the arrow image points to the class the connecting object is partly made up of.

Java, C++

single inheritance = means one immediate parent class
Printer p;
LaserPrinter l;

Class Printer {
class LaserPrinter : Printer
class Laser extends Printer
class Laser extends Printer
All others

If the only difference is what would be in the fields not the the behaviors or added fields there is no Inheritance you just would have two different objects passing different field data.

Inkjet is-a Printer
Laser is-a Printer
Inkjet is-s Laser – X

Even though a class has been extended the extended Class is still general. It is a specific Generic class Not an Object. As we go down the classes get more specific but they aren’t objects, this is still a type relationship.

A Subclass has two Types it is itself and it’s parent. Inheritance is a type relationship.

Reference Object
Printer t = new Laserjet();
that a is this every ← interpret right to left thus ( every LaserJet is a Printer ) Polymorphism
here you get to use “t” with any Printer you want not just printer or inkjet or laser
** Don’t have to start by knowing which one you want. It’s like Just in Time ordering or outsourcing the work to special shops at runtime if unknown at design time. This is a powerful allotment,
This is Polymorphism you can change a thing into its child or instantiate its subClass

Printer p = new Printer();
Laserjet l = new Laserjet();
every “l” is a “p”

var t:Printer;
if () { t = new Laserjet(); }
else if() { t = Inkjet(); }
else if() { t = ColorLaser(); }

*** “new” is the allocated memory which makes a var an object

Inheritance is a type relationship A is the superclass ← B is inheriting from A. B is the subclass and includes all that A has.
A is of type: A
B is of type: B and A

if Subclass C it would be of type : C,B,A
Each object of a class that inherits another will have enough memory for all included
You cannot separate them. All A’s are not B’s A will not have any knowledge of what’s in B or C
You can add things to ‘B’ that are not in ‘A’
You create B by extending A

The beauty of inheritance is that you don’t have to change the meaning of a superclass when you want to add to it, just extend it and add to it in the subclass

*in UML your arrow always points to the base or parent class.

There are no penalties for having multiple classes but there is a penalty for using one big class.

If in your requirments to read something like “new type of A” or “a specialized version of A”. These words are triggers that you should use Inheritance.

Subclasses cannot count for more than there are Superclasses because it is a special version of it’s superclass. If there are 100 supers and 20 subs that 20 is counted for in the 100.

Related to fields in a Class : don’t put everything and the kitchen sink in the superclass. you should have fewer fields and fewer methods in each. If you are getting to specific break out and make a subclass.

If you are building and you realize that subclasses are sharing fields not in the superclass go back and add that field to the SuperClass.

One immediate superclass is single inheritance.
Having more than one immediate superclass is multiple inheritance.

INHERITANCE : something is a something = the same but, a special kind of

Other relationships
… will use
→ Has
→ Uses
– these two relationships don’t have a type relationship

Is the relationship possessive or dependant.
Possession or Aggregation
“Has” => ownership:
=> whole/part: a page is part of a book without all the pages there is no longer a book;
car has windows, seats, gear shift, doors
=> container : book is a container of pages; a car is a container of all it’s parts
-> component* : has that component not uses it; component of

*only one of these need be true, there is no other expectation.

AGGREGATION : something has-a something.
*0..n or 0

*If you needed all to be true this is called Composition

Composition is aggregation plus => # of part > 0
when you are are expecting to have a certain number of things. more than zero parts not just a container, not just a component or part. Not whole/part it must be the whole.

COMPOSITION : something has-at least something
* 1:Many or 1:n

A steering wheel does not need a car to be a steering wheel but a Car needs a steering wheel to be a Car. The container is not complete without it’s parts. A package deal is Composition.
zero is not

Composition is a stronger form of Aggregation

( see UML page 1)
Dependency or Association (uses)

Association => uses
You or a thing do not own another thing nor do you or the thing contain it. not aggreegation or composition
You are not that thing no inheritance
If you use it this is Association

ASSOCIATION : something uses something
Without a specific class the other or dependent class cannot achieve a requirement or purpose. It doesn’t need to own it. But it needs to have access.

The relationship of a Gym to its equipment is Composition
The Relationship of a Member to the gym’s equipment is association.
The Member can never own the Equipment and the Gym is still a gym so long as the equipment is there even if there are no Members.

To use the needed class the dependant class will invoke or call a method on the needed class
When an object calls a function on another object it is ASSOCIATION

**All Programmers will not come up with the same solution, it doesn’t make one correct over the other. The key is to be sure that the Design satisfies the requirements.
**You may not get the relationships correct at first. You might have to cycle through a few times.

February 14, 2013 / Danii Oliver

Procedural – Object-Oriented Analysis and Design

What problems were we trying to solve ?
The Basics of programming is creating …
types, variables, function, subroutines, modules

Programming and OOP is about getting further away from Machine language and closer to human language

Procedural – doesn’t allow for reuse
– abstract datatypes
– would have to write the rules in a function
– where to put data nothing else or if it should have something else

Type allows what values can be stored based on a certain range
i.e. int is whole numbers only neg or pos
uint only positive whole numbers

user defined type or abstract data type – not predefined and used to define something more
|–>Student {
string fname
string lname
int age
this is the limit in Procedural Language
student s; or var s:student;

Type Checking – compiler checks to make sure all vars are compatible and that and operators make sense for the type

Semantics or Rules is about checking that the type contains what it is suppose to.

Global Variables can do more harm than good. Fact!

void foo(){
int x;
y = x;
– inside the { } is the scope of the function or code block the var inside is Local
void Main{
x = x+5; [[ error x is undefined because x is local to foo ]]
if at TOP int y; //Global
then y can be cast anywhere
void Main{
x = x+5; [[ error x is undefined because x is local to foo ]]
y=y+20; [[ y will get recasted ]]

abstract data type does not answer a query the function does but there is no communication

OOP goes from
[ Data ]
[func][func][func] to
[ data | behavior & cap ] [ data | behavior & cap ] [ data | behavior ]
– not all things but the things that are in common.

** Procedural is a Child that knows but others must speak for them
** OOP is a person who can speak for themselves

Classes are classifications for complex objects made of various variable declarations or fields whose scope is the class

Classes describes how an Object is made, what it can do, can’t do, allowed to do

To go from having a Class ( or your recipe ) to an Object we Instantiate the class which gives is a memory block. Type determines amount of memory. Class = Type.

Instantiation is the process of requesting the amount of memory needed for Class as an Object
now all you need to do is say
student s; ⇒ give me the amount of memory needed now you have an object
new student s; we use “new” so the compiler knows to check how much is needed and get it.

Instead of making an ab.dt that is just data in OOP we can know what the element can do with the data. The blueprint is the Class, if you want it to not be able to do something it should not be in there.
Class describes what an object does and how it does it.

when trying to build a program I am not looking for procedures I am looking to implement an Class Object

The task at hand is the figure out what your classes are to model in your program
student, furniture, light, door — ask yourself what do you need to “represent” this is a real thing.
step two
what are they suppose to do, why are they there, what’s their role, what are their capabilities

NFL Team
program = team
classes = positions on the team
now how many will you need and which ones, why do you need ?
– inside the class are variables &
– behaviors are your functions or “Method” it allows the class to do something ( the action or what it can or can’t do )
– the class doesn’t do anything it defines what the object can do

Job Description is the class – a definition of something
The Candidate is the Object – the object should and will only do what is in the class.

at Runtime you create variables of the classObject

class Student {
int age;
string fname
string lname
string Read() {…}
int getAge(){ return age }
int setAge() { this.age = age; }

** Being able to design a system is higher up the food chain than being able to program it. The value is being able to design something that makes you not the commodity and makes you invaluable!
** Those who can marry multiple focuses will have more value especially when married with strong Foundation

Unified Modeling Language: defines the classes that you have and what their relationships are to each other
– static view of the program, a blueprint no paths from point A to B just where they are
– not a flowchart which shows procession

Class : It is best to name your class descriptive of the real word element you are representing
| student |
| |
| |


Get every new post delivered to your Inbox.

Join 142 other followers

%d bloggers like this: