List Info

Thread: Herency in Director (javascript)




Herency in Director (javascript)
user name
2005-12-30 13:02:10
Thank's
But yesterday director hangs all the time cuz of the:

function holyday ()
{
}

function xmas ()
{
}

xmas.prototype = new holyday ();

When i remove the last line director works fine (these 2
objects are in a 
single moviescript).

And "A Zavatone" it's right... it's not
"herency" it's "inheritance" i 
guess... im not a programmer, and in my country this
programming resource is 
called "herencia".

Well, good luck,
And thank you!

----- Original Message ----- 
From: "Andrew Phelps" <amp5315rit.edu>
To: "Director - Shockwave - and Flash Game
Production" 
<dirgames-lnuttybar.drama.uga.edu>
Sent: Thursday, December 29, 2005 5:08 PM
Subject: RE: [dirGames-L] Herency in Director (javascript)


actually, its

function myNewClass() {
...
}

myNewClass.prototype = new BaseClass();

The "trick" that differs from regular ECMAScript
1.4 is that Director 
compiles its scripts IN ORDER from first to last in a given
cast, and IN 
ORDER from first cast to last cast.  Your BaseClass script
MUST appear 
BEFORE your myNewClass script - otherwise the setting of the
prototype will 
barf because it doesn't yet have bytecode for how to
construct a new 
BaseClass.

Also, if you change the BaseClass in any way, you will need
to recompile not 
only the BaseClass, but also the myNewClass, because the
reference that the 
prototype of your new class holds could still be an old (and
now 
invalidated) BaseClass object.

Moral of this story - compile the base class first, then
compile the new 
class, then run.  Works like a charm.

-A

________________________________

From: dirgames-l-bouncesnuttybar.drama.uga.edu on
behalf of Sebastian Lucas
Sent: Thu 12/29/2005 11:45 AM
To: Director - Shockwave - and Flash Game Production
Subject: Re: [dirGames-L] Herency in Director (javascript)



Danny,

> I'm no expert on JS syntax in Lingo, but this line
looks weird to me.

Sure, but it's Javascript syntax in director not in lingo.

> You're setting the prototype of a function to an
object? What does that
> even mean?

In ecmascript (as far as i know) herency work in that way,
setting the
prototype of an function (CLASS) to the base class.
In c++ would be:

class cclass: public cbaseclass

In javascript it's:

function cclass ()
...
cclass.prototype = new cbaseclass ();

All the functions and variables from cbaseclass are
"copied" or "instanced"
into cclass.
I put "CSprite" and "CClipper" and the
first "C" means "class" later in the
code i'll use something like this:

var dummyvar = new CSprite ();

> And CClipper () is just the value 0 anyway, so 'new
CClipper()' is the
> same as 'new 0' which doesn't make any sense.

Why is 0? I don't  understand that. You mean
"null"?
CClipper it's an object, class... when i put "new"
that means a new instance
of CClipper.

Whatever, i don't know if this's it:

class.prototype = new baseclass ();

or:

class.prototype = new baseclass;

or:

class.prototype = baseclass ();

Hum, nevermind, i think the shockwave plugin isn't good for
me. =(
I wanna cry.

Regards,
Sebastian Lucas
_______________________________________________
> dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
> http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l

_______________________________________________
dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l





------------------------------------------------------------
--------------------


> _______________________________________________
> dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
> http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l
> 

_______________________________________________
dirGames-L mailing list  -  dirGames-Lnuttybar.drama.uga.edu
http://nuttybar.drama.uga.edu/mailman/listinfo/dirgames
-l
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )