Tuesday, 8 July 2014

The document class

So now we have had enough to begin I would say! Lets proceed to the next, hopefully the last portion before we start fillin up something in the blank space that we already have created in 'Classes and OOP'. Shall we?

It's called the document class. Basically the main class of your program/tool/application/whatever. It's the class which starts your program and as I said earlier, we gotta extend either the Sprite/MovieClip classes in order to create our SWF file.

So, how does it works?

The very reason for programming in AS3 is basically, creating a SWF file with the things we need. Like creating a motion picture (like .gif) by ourselves. And not to forget the best part, its user interactive!

To answer the question, the Sprite/MovieClip classes creates the SWF file. Fair enough? After all, no one wants the user to be interactive with nothing! ;-) Would we?

Let's create our document class now. Here we go!

 import flash.display.Sprite;
 public class Sample extends Sprite {
 public function Sample() {
 private function init():void {
 // code goes here

Well, this is a basic template class which extends the Sprite class with a constructor. I have given only one line of code in the constructor and that is because, its a practice of a good developer ;-) (Not to have too many lines of code in a constructor). I know the page is still empty. Let's fill in the space in the next post. Trust me!