Search the web
Sign In
New User? Sign Up
openLingo · openLingo Code Library
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Real people. Real stories. See how Yahoo! Groups impacts members worldwide.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
javascript in MX 2004   Message List  
Reply | Forward Message #616 of 643 |
Hi everyone,

I have been trying out the new javascript functionality and although
I expect I am not the only one, there is precious little
discussion/comment/opinion around so I thought I might start some.

I like the idea of using javascript over lingo for several reasons,
but there seem to be a few problems with the object oriented parts.
Admittedly, as a C++ programmer, I thought it unfortunate that java
didnt have "friends", so my standards are quite high. Moving to
lingo, I found Parent/Child scripts quite frustrating, but,
similarly to everyone else, you find ways to do what you want to do
which work, and you stick to them. If you move to using javascript
then it seems you need to go through this process again.

Firstly, I cant find way anyway for behaviours to inherit.
Inheriting in behaviours (instantiated through the beginSprite
rather than the new method) was a bit flaky before; initialisation
was the main problem (e.g. you needed to pass the spritenum down to
the ancestors constructor). With javascript you dont directly
instantiate the base class - you set the prototype and the
constructor gets called and the properties get set immediately
before the subclass gets instantiated (but only when you new
something - not when you beginSprite it)! So, using inheritance in
behaviours never worked as would like and was best avoided. With
javascript this decision (unless you know better) is made for you.

Overriding methods and properties works better (in some ways) in
javascript than in lingo - in lingo you could end up with an
inherited method updating a property in the ancestor which was
hidden by a property of the same name in the child depending on
where "me" came from. In javascript, "this" seems to reliably
correspond to the child (as long as you dont start playing with the
__proto__ property).

I tried to use the __proto__ property like I might use the ancestor
property (or use callAncestor), but I cannot see a way to call a
method on a base class once it has been overridden. I often used
this to chain initialisers, for example.

Initialisation is an issue therefore. As the contructor of the base
class gets called before the constructor of the subclass it doesnt
make sense to initialise properties except in leaf classes. Where
initialisation is complex (e.g. objects registering with container
objects) it seems best to keep this completely separate from the
construction. Currently, I am thinking that using static/class
methods (which you can now do), with the instanceHandle passed as
the first parameter is the most effective (it allows calls to be
chained without unnecessary initialisation or instantiation).

Presumeably many of you have come across these issues before from
using javascript in browsers, but I expect that you are prepared to
write a lot more code in Director than you would write for a
browser, so OO is more likely to play a major part.

Oh, one other thing, you cant inspect a javascript object like you
can a lingo object in the debugger or object inspector (now how hard
can that be!).

Ben





Tue Mar 9, 2004 7:35 pm

benstjohnston
Offline Offline
Send Email Send Email

Forward
Message #616 of 643 |
Expand Messages Author Sort by Date

Hi everyone, I have been trying out the new javascript functionality and although I expect I am not the only one, there is precious little ...
benstjohnston
Offline Send Email
Mar 9, 2004
7:35 pm

If you look at the big picture, you will find (feel) that the JavaScript in MX 2004 has a version 1 feel. I would wait to DMX 2005 prior to considering...
David Turk
mediasense_oz
Offline Send Email
Mar 9, 2004
10:17 pm

You are probably right - its just a shame that parent/child lingo is only at version 0.9 alpha! At least lingo works with the debugger though - trying to step...
Ben St Johnston
benstjohnston
Offline Send Email
Mar 10, 2004
8:15 am

... From: "David Turk" <mediasense@...> ... JFTR, I think that openLingo should progress as previously forseen, but we should make sure the...
Robert Tweed
robert_tweed
Offline Send Email
Mar 10, 2004
12:14 pm

That might not always work. If you are providing a library of "classes" which people can extend, then you should provide them as javascript and lingo, as you...
Ben St Johnston
benstjohnston
Offline Send Email
Mar 10, 2004
1:10 pm

... From: "Ben St Johnston" <ben@...> ... But that's not what we are doing. We are providing an object-oriented toolset, which people can...
Robert Tweed
robert_tweed
Offline Send Email
Mar 10, 2004
1:49 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help