# Classes

**URL:** <https://forum.kirupa.com/t/classes/57102>\
**Category:** Uncategorized\
**Created:** [July 10, 2004, 5:46am UTC](https://forum.kirupa.com/t/classes/57102 "2004-07-10T05:46:11Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bodyvisual](https://yyz1.discourse-cdn.com/flex011/user_avatar/forum.kirupa.com/bodyvisual/32/564_2.png) [@bodyvisual](https://forum.kirupa.com/u/bodyvisual)\
**Post date:** [July 10, 2004, 5:46am UTC](https://forum.kirupa.com/t/classes/57102/1 "2004-07-10T05:46:11Z")

</div>

All right, so what exactly are classes? I’ve heard about them in PHP and flash, and i’d really love to know what they’re useful for and how you use them.

thanks in advance

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2004, 6:09am UTC](https://forum.kirupa.com/t/classes/57102/2 "2004-07-10T06:09:39Z")

</div>

_bump_

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2004, 6:42am UTC](https://forum.kirupa.com/t/classes/57102/3 "2004-07-10T06:42:02Z")

</div>

Best bet is do a google search. It’s not a quick topic to understand.

Basically, a Class is a broad definition for a series of complex objects. Just like all the students in a class are not the same, but they have something in common - which is why they are in the same class.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2004, 9:20am UTC](https://forum.kirupa.com/t/classes/57102/4 "2004-07-10T09:20:08Z")

</div>

A class is basically a custom data type.

Here’s a simple class:

```auto

class Simple
{
    private var simpleVar:Number;

    public Simple(s:Number)
    {
        simpleVar = s;
    }

    public getSimpleVar()
    {
        return simpleVar;
    }
}

```

then to use it:

```auto

var mySimpleClass:Simple;
mySimpleClass = new Simple(420);
trace(mySimpleClass.getSimpleVar()); //420

```

that’s all there is to it!

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2004, 4:17pm UTC](https://forum.kirupa.com/t/classes/57102/5 "2004-07-10T16:17:06Z")

</div>

so is that flash? and what are the : for? are they identifiers?

🙂

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 10, 2004, 4:49pm UTC](https://forum.kirupa.com/t/classes/57102/6 "2004-07-10T16:49:23Z")

</div>

Carixpig is right definately not a simple subject to understand. But in my opinion one of the most fundamental ideas that is required to do **anything** in programming today, whether that be C++, Java, or Kernel OS programming.

Classes are one model (basically the back-bone) that helps to make up the OOP (object oriented programming) idea. Classes in the most simplest form define an object, so there-fore a class is a object definition.

Objects are anything that you can think of, the string attribute in flash is an object of type string. The idea stems from the real world. You have before you a monitor, that monitor is by definition an object (in the real world). But progmatically it could also be an object. For instance, when you talk about that monitor you would say it has certain qualities (or attributes 🙂 ) to define it specifically like: size, color\_depth, resolution, and model\_type.

So to write that progmatically we would do this.

```auto

class monitor {
	 [color=darkorange]public [/color][color=royalblue]var [/color][color=lime]size[/color]:[color=purple]Number[/color];  
	 //What was done here was i declared an attribute of the class, monitor. //That attribute is accessable from anywhere in the class or outside it ([color=darkorange]public[/color]).  
//Then I declared it to be a attribute of the class monitor ([color=blue]var[/color]).  
//I then gave that attribute a name: [color=lime]size[/color]
[color=black]//I then gave that attribute the type: [/color][color=purple]Number[/color]
[color=black]	 
	 function monitor() {
		  //What I am doing here is defining the original state of the
		  //monitor classes, attribute of size to 26 inches.[/color]
		  //this function is called when you define an object of monitor in
		  //your main FLA. ie gateway = new monitor();
		  //trace(gateway.size) will show 26!  
		  size = new Number(26);
	 }
}

```

This is a real basic example and the kirupa site has a real good tut on the **new** AS2 OOP programming model (btw this is AS2 only script). Hope this illustrates what Classes are!

-Ryan

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 11, 2004, 12:17am UTC](https://forum.kirupa.com/t/classes/57102/7 "2004-07-11T00:17:46Z")

</div>

wow, thank you sooper much! that makes SO much sense! i will definetly check out the tute.

thanks for explaining that so well!

😃

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex011/uploads/kirupa/original/3X/6/2/621e5c11736f46532526e61be85940af4230f3e5.png) [@system](https://forum.kirupa.com/u/system)\
**Post date:** [July 11, 2004, 12:48am UTC](https://forum.kirupa.com/t/classes/57102/8 "2004-07-11T00:48:08Z")

</div>

Your welcome!
