The compiler performs compile-time type checking only if a variable
declaration has a specified type. In your 1st case there is no type
specified, so the compiler does not care about the proper usage of
properties and methods. In the 2nd case it checks for the existence of
properties and methods referred - because you included the type into the
declaration -, but since the MovieClipLoader class has no onLoadStart
method, you cannot refer to it and the compiler throws an error.
Actually the onLoadStart is an event, which can be catched by an event
listener. This is a little bit different than the simple callback
methods of LoadVars, XML and similar classes. Basically there are
three event handling mechanisms in Flash:
1. simple callback functions (this is the oldest one)
2. listeners (a la ASBroadcaster, since Flash 6)
3. event listeners (a la EventDispatcher, since Flash 7)
The MovieClipLoader uses the 2nd one.
And one more note: the type checking can be avoided (even if you
specify the type of a variable) if the specified class is defined
as dynamic (the MovieClipLoader is not dynamic). You can check wheter a
built-in class is dynamic or not by looking into the intrinsic classes
in the C:\Documents and Settings\user_name\Local Settings\Application
Data\Macromedia\Flash 8\en\Configuration\Classes\FP8 folder.
Attila
a> the two following scripts seems to be the same, but different choice get
different performance .
a>
a> 1 var MCL = new MovieClipLoader();
a> 2 var MCL:MovieClipLoader = new MovieClipLoader();
a>
a> when I use 1, I can just write my script like this:
a> MCL.onLoadStart = function (t) { ... }
a>
a> But When I choose 2, the IDE tells me that the MCL object doesn't have the
'onLoadStart' method.
_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org