The keyword static keyword is also more important in ActionScript 2.0. If an attribute is static, then we can call it directly ...
static (Static) keywords are also important in ActionScript 2.0. If an attribute is static, then we can call it directly without having to use the instance of the class. Most properties are manipulated by the Instance of the class, which means that they are not static.
Example:
Create a myClass Instance myinstancemyinstance = new MyClass ();//Call one of the properties trace (myinstance.property1);
If this attribute property1 is static, then we can call it directly:
Call Trace (myclass.property1) directly through the main class;
In Flash, a class with the most static attributes may be date, and all of its properties are obtained by calling the date class directly. We can do this directly: Date.getutcminutes () instead of creating a new Instance and then using this Instance to get the desired attributes. It can be said that static properties or methods are created only once in the main class without having to replicate one in each class member.
We can create static properties or methods ourselves. Here is an example:
Class Geometry { static function getdistance (MC1, mc2) { var distance:number = math.sqrt ((mc1._x-mc2._x) * (mc1._ x-mc2._x) + (mc1._y -mc2._y) * (mc1._y-mc2._y)); return Distance }}
The static function Getdistance () returns the distance between two MovieClip. We can call it in other files like this:
Distance_between_2_dots = Geometry.getdistance (dot1, Dot2);
If you remove "static" and then imagine calling Getdistance () like the method above, you will get the following error message as 2.0:
The property being referenced does is not have the static attribute