Before we explore learning how to "speak" ActionScript, you need to learn the basic structure, format and aspects of the language.
Class and Objects
In object-oriented programming, classes and objects are the basis of all functionality. Objects on their own, however, are useless unless they are defined by a class. A class is the "blueprint" for an object's behavior, functionality, and characteristics.
In the context of ActionScript, a class is the equivalent of a blueprint. A class defines how an object is constructed(how it is introduced to the application); an object's properites; an object's methods; and how and object communicates(its event).
Classes are not stored in the Flash document itself, but in separate ActionScript files. They are imported into a script either automatically when a movie is compiled or by using import directive in your code.
An object is a copy of a class either in code or physically on the stage, or an instance of a class. If you construct more than one object of a class, you have multiple instances of a class.
Multiple objects of a single class can run autonomously from one another. Once an object of a class is instantiated, you can set its properties, call its methods, and listen and respond to its event.
Ex: var mc:MovieClip=new MocieClip();
Here we have created mc object for the class MovieClip. Using this object we can chance the object properties.
Ex: mc.x=100;
mc.y=100;
If u want to add the MovieClip into the stage, addChild(); function helps u.
Ex:
addChild(mc);
now the mc is added into the stage.
you can add the "mc" to any other object that name is "man". U use the syntax:
Ex: man.addChild(mc);
No comments:
Post a Comment