Reputation: 1779
UPDATE: Found some nice info on AVM2. I haven't been able to spend much time with it, but it definitely covers $init and $cinit (as well as $iinit, and a lot of other things). I'll post a response to this question if I get a good handle on the answer before someone else puts something up.
Got pulled into a long thread of link-hopping and googling about this today, but still don't have much of a grasp on what $cinit and $init are.
I care because I learned today that $cinit and $init are interpreted (by the FP, if I understand correctly), while everything else is compiled.
I think that $init refers to the given class's constructor function, and $cinit refers to the constructor of the object that creates the class. ... something like that...
Can anyone set me straight on this, or at least point me in a helpful direction?
Thanks.
Upvotes: 1
Views: 1085
Reputation: 2194
This is an old question, but as I know the answer I'll post here.
$cinit
is the method that is called before any use of the class is required. It initializes all static members and runs any code that is in the static initializer. Think of it as the classes own constructor. For instance, if you had the following class in AS3:
public class SomeClass extends Object {
static private const SOME_STATIC_VAR = 4;
....
}
Then the $cinit
method would run before the class was ever used or even made reference to, and it would initialize the memory for SOME_STATIC_VAR
and set its value to 4.
$init
is the classes instance initializer. It's basically the classes constructor. For example:
public function SomeClass() {
super();
return;
}
Hope thats enough detail for you!
Upvotes: 1
Reputation: 1
$cinit
is to construct all static variables while the class are used for the first time.
Upvotes: 0