ParentChild Lingo - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

ParentChild Lingo

Description:

Parent-Child Lingo. An Intro to Object-oriented Programming ... Parent/Child Lingo. Parent. Represents prototype ('class') doesn't ... related Lingo code ... – PowerPoint PPT presentation

Number of Views:23
Avg rating:3.0/5.0
Slides: 10
Provided by: ericis
Category:

less

Transcript and Presenter's Notes

Title: ParentChild Lingo


1
Parent-Child Lingo
  • An Intro to Object-oriented Programming

2
Basic OOP Concept
  • Encapsulation of features (properties) and
    actions (handlers)

Object 1 Data Methods
Object 2 Data Methods
3
Parent/Child Lingo
  • Parent
  • Represents prototype (class)doesnt actually
    exist
  • Defines properties of that object type
    (equivalent to local variables)
  • Defines custom handlers/functions for that object
    type
  • Definitions placed in a parent script

4
Parent/Child Lingo
  • Child
  • An instance of an object
  • Contains a unique copy of the properties,
    handlers
  • Created using new function
  • myObject new(parentScript)
  • Exist in RAM, not in Score or Cast, though
    objects can be assigned to sprites

5
Example Note
  • Properties
  • pitch
  • duration
  • note head
  • stem direction
  • location
  • attached elements
  • accidentals
  • articulations
  • dots
  • Handlers
  • Change location
  • Change stem direction
  • Change pitch
  • Change duration

6
Why OOP?
  • Helps manage complexity
  • keeps related Lingo code together
  • Note parent needs to know only about notes,
    and knows everything about notes
  • Provides for reusable components
  • a score includes multiple notes
  • can change internal implementation without
    affecting external access

7
Example Math drill
8
Writing a Parent Script
  • Create a new script
  • Set its type to Parent
  • Declare properties first
  • Include an on new handler that is called when a
    new object is created
  • may include initialization parameters
  • Provide handlers to set/retrieve property values

9
Creating a Child Object
  • use the New function
  • keyword script and name of the parent script is
    first parameter
  • initialization variables for the on new handler
    follow
  • assign result of function to a variable or add it
    to a list
  • myObject new(script parentScriptName, param)
Write a Comment
User Comments (0)
About PowerShow.com