Dynamic ClassThere is one type of Class we have not yet discussed the Dynamic Class. Although we can create dynamic classes their use should actually be avoided, since we bypass datatyping as shown in the following example. In this example we are not giving any datatype to myVar, but nevertheless we get the correct trace action without any error message.
FLA file script:
import as_scripts.*;
var a:DynClass = new DynClass();
a.newClass();
Class script:
dynamic class as_scripts.DynClass {
function DynClass (){
}
function newClass () {
myVar = "Hello";//NO datatyping
trace(myVar);
}
}
If you use dynamic classes you may run into trouble, if your script does not do what it should do, because of the lack of datatyping. In the next lesson we will discuss a number of special cases. |