2. • Flash Platform Consultant
• Lecturer Devine
• Adobe Community Expert
• Technical author
• Full time web geek
3. Creativity is a mental process involving
the generation of new ideas or concepts,
or new associations of the creative mind
between existing ideas or concepts.
4. Programming is a the process of writing,
testing, debugging and maintaining the
source code of computer programs.
5. What will we talk about?
• Object-Oriented Programming
• Classes and instances
• Inheritance
• Encapsulation
• Basic trigonometry
• Distance between points
• Polar and Cartesian coordinates
• Experimentation
• BitmapData
• Sound Spectrum
8. Classes
• Classes are blueprints of functionality
• Allow for reusable and modular code
• Contain methods (functions) and properties (variables)
Ball class
9. Instances
• Instances (objects) are copies based on a class blueprint
• Instance property values are independent of its class
Ball class
Ball instance Ball instance Ball instance
11. HelloWorld.as
package {
public class HelloWorld {
public var name:String;
public function HelloWorld(value:String) {
this.name = value;
trace(“Hello world from “+ this.name);
}
}
}
12. HelloWorld instances
var myWorld:HelloWorld = new HelloWorld(“Peter”);
// Hello world from Peter
trace(myWorld.name); // Peter
var otherWorld:HelloWorld = new HelloWorld(“Barack”);
// Hello world from Barack
trace(myWorld.name); // Barack
13. Inheritance
• Classes can extend each others functionality
• Each class can only inherit from one super class
• Use the “extends” keyword
Animal class
Dog class Cat class
Tiger class
15. Encapsulation
• Protect the inner workings of your class
• Access modifiers (public, private, protected, internal)
• Use getter/setter methods to provide access
getter/setter
other class
class
internals
16. Access modifiers
• public - accessible from anywhere
• private - only accessible from within the class
• protected - only accessible within class and subclasses
• internal - only accessible within same package (default)
17. Getter/setters
• Looks like a method, behaves like a property
• Provides a single entry point for setting a property
• Useful for input validation
private var _age:Number;
public function get age():Number {
return this._age;
}
public function set age(val:Number):void {
if(val >= 18) {
this._age = val;
} else {
trace(“you are too young”);
}
}
18. Account.as
package {
public class Account {
private var _email:String;
public function set email(val:String):void {
if(val.indexOf(“@”) != -1) {
this._email = val;
} else {
trace(“invalid email”);
}
}
}
}
var myAccount:Account = new Account();
myAccount.email = “peter.elst@gmail.com”;
31. flash.display.BitmapData
• Allows you to get pixel level access to bitmaps
• Work with color channels
• Perform bitmap operations
32. SoundMixer.computeSpectrum
• Returns spectrum information of sound
• ByteArray with floating point values between -1 and 1
• Raw wave form or Fast Fourier Transform (FFT)
• Doesn’t work for microphone input (yet) :(
• see www.getmicrophone.com
33. Books
Foundation ActionScript 3.0 Animation “Making Things Move”
Object-Oriented ActionScript 3.0
Websites
www.gotoandlearn.com
www.levitated.net
Get in touch
Email: peter.elst@gmail.com
Blog: www.peterelst.com
Twitter: peterelst
Thank you!