Objects
Top  Previous  Next


SWiSHscript is an Object-Oriented Scripting language.

The term 'Object-Oriented' is primarily a programming concept that broadly means that an Object is any item that contains data and behaves in a defined way. An Object-Oriented language sorts similar Objects into a 'classes'.

The class to which the Object belongs defines:

·the type and meaning of the data that the Object contains (properties)  
·the way in which the Object and data can be manipulated (methods)  
·the way in which the Object behaves during certain conditions (events).  

For example, consider a class that defines animals. That class could contain the animal's name, type, number of legs, noise and so on. These attributes would be properties. Your pet cat Fleebag and your pet dog Growler could both be considered Objects belonging to the class animal.

The class animal could be (partially) defined as follows:

Properties
·Name  
·Type  
·Noise  
·Angry  

Methods
·MakeNoise()  
·MakeAngry()  
·Walk()  
·Feed()  

Events
·OnAngry()  
·OnHungry()  
·OnTired()  

When referring to properties and methods within an Object, the dot '.' character is used to delineate the object name and the contained property / method or event.

onHungry {
    pet1.Name = "Fleebag"; // assign the name "Fleebag" To
 pet1.
    pet1.Feed();   // feed the cat.
}


The method Feed() will be executed once pet1 becomes hungry.

Movies, Sprites, Buttons and Text Objects can all be considered to be Scripting Objects.
These Objects have pre-defined properties, methods and events associated with them.