02
object

objects

a central programming theme is the cycle of writing code that makes other code easier to write. programming languages themselves begin the cycle, offering built-in groupings of basic and common functionality. these groupings are called objects.

objects are containers for collecting properties and methods under a common theme.

physical examples

conceptual examples

flash objects

objects are commonly named after nouns, to provide insight into the logic behind the properties and methods it collects.

properties

...represent characteristics of an object ...are commonly named after nouns and begun with lowercase letters

methods

...expose actions the object can perform ...are commonly named after verbs and begun with lowercase letters but have parentheses at the end

parameters

...provide information the method needs to operate and that's what the parentheses are for—passing parameters into the method. multiple parameters are separated by commas. but how do we know what order the parameters should be in, or the ranges of acceptable values? we need to read the documentation, and look at the method signatures. parameter order, units and context are all determined by the method (need to read the documentation).

dot syntax

properties and methods of actionscript objects are accessed using the . (dot, a.k.a. period) operator
graphics.drawRect(20,50, 70,100)
point.x
point.offset(2, 1)
character.favoriteFood
character.jump(5)
Math.PI
Math.round(5.7)
trace("hello")

scope

when we ‘access’ properties and methods, the word implies getting into, which is accurate. program elements in the run-time environment exist in different levels of containment, called scope .

local

object properties and methods do not exist outside the object
 PI
 Math.PI

global

built-in objects and some loose methods exist in global scope and are always available.