PDA

View Full Version : movieclip.prototype ???


morosa
06-05-2006, 10:06 PM
Okay, okay...I'll admit, I'm a little rusty around the edges...so please, forgive me now!

To that end, what the heck is movieclip.prototype.scaler = function(friction) {
//do some stuff
}


Where, "scaler" is the name of the function (hehe..I think!)

First off, it only works when published to Flash player 6 w/AS 1.0?!? Secondly, what was it replaced with for newer Flash Player version, i.e. 7 & 8 players??

I've tried converting it to the following function, as in:

function scaler(scale, friction) {
//do some stuff
?

But that just breaks it completely!? Which is strange, b/c in theory, it should work, no?

Anywho...any help and/or advice on this prototype jibjab would be much luved!

Thanks in advance!


mo

senocular
06-05-2006, 10:16 PM
The prototype object is a shared object which shares all of its definitions with instances of the object to which it belongs. In other words, everything defined in MovieClip.prototye is also available to all instances of MovieClip. Everything defined in Array.prototype is also available to all instances of Arrays.

Why that particular code only works for 6 is because of capitalization. MovieClip <- as you can see, should be spelled with an M and a C. Flash 6 and below didn't care about caps.

Just using function wont work because it wouldnt be accessible to all movie clips. However, you could go through and assign it to all movie clips that use it and it should work the same, i.e.

function scaler(scale, friction) {
//do some stuff
}
mc1.scaler = scaler;
mc2.scaler = scaler;
mc3.scaler = scaler;
// etc.

morosa
06-06-2006, 12:53 AM
Senocular, again and as always, thank you very monkey! ;) This is very helpful, and now somewhat obvious! Doah!

So did AS 2.0 Classes replace the MovieClip.prototype? Or is that a completely different ball game altogether?!? Doah!

Thanks brotha from another motha!

- mo

senocular
06-06-2006, 01:09 AM
AS 2.0 Classes still use the prototype object but just behind the scenes. All non-static functions defined in an AS2 class is defined as a prototype. Same applies to variable members (which is why you have to define objects and arrays in the constructor or they are shared among all instances of the AS2 class).