Lingo vs Javascript
Just wondering how many of you are actually using javascript
and/or mixed
language projects.
And has anyone actually switched to using js since it was
introduced?
Sure, js's syntax is common, and it was supposed to make
director more
attractive for new users, and it is stricter, resulting to
tidier code, plus
supports several neat stuff, and it's item accessing is zero
based. All good
so far. However, there are some handy lingo-specific concepts
that are not
js compatible. Most important perhaps, the ability to pass
1-2 arguments to
properties. In lingo, when you use string.char[1], it is
interpreted as:
a. attempt to get property #char, passing 1 as argument to
the property
request.
If property arguments are supported by the object, and if '1'
is valid for
.char, then return the result. Otherwise:
b. return the property .char, and try to perform a getAt(1).
With js, there is no first step - it is always two commands-
where with
lingo it is either one or two.
Js is stricter, lingo is (or at least tries to be) smarter
and faster.
But in programming, 'smarter' also means more checks, so
smarter code could
also be slower code. In the above example, if step a
succeeds, then lingo is
faster, otherwise it is slower. Btw, since js doesn't support
passing
arguments to property requests, director(native) or third
party(xtras) code
that expect such arguments will fail ( which is the js
equivalent for "ab
cd".word[2] ? )
Anyways, back to the original question. What is it for you?
JS or Lingo?
> No offense meant to the fans of Lingo. I don't think
it's crappy or
> anything;
> I just prefer JS.
None taken. (how could?).. Though personally, I'm spending
more time coding
c (js-like syntax) than lingo, I still prefer lingo when it
comes to
director. And that's because of the generally more compact
code for command
line tests / small scripts. For bigger projects perhaps using
js is better.
But, though very familiar with both director and js syntax,
actually using
js with director still requires getting accustomed to... Not
to mention
referencing the help files...
"Ex Malterra" <[email protected]> wrote in
message
news:g64vp3$e49$[email protected]..
>I much prefer JavaScript. I never liked Lingo syntax,
probably because the
> first scripting I ever learned was JavaScript. JS is the
reason I upgraded
> to
> MX 2004. Having mostly used C++, C#, Java, JavaScript
and ActionScript 2.0
> I'm
> simply more used to their syntax. Sure, some things
require just a little
> more
> to do in JS vice Lingo... like symbol("someSymbol")
instead of
> #someSymbol, but
> for me personally it's more than worth it. And I gotta
tell ya, try/catch
> is
> great! The error info thrown isn't always especially
useful, heck it's
> usually
> not useful at all for that matter, but you generally
know what might go
> wrong
> in your code at those points anyway.
>
> No offense meant to the fans of Lingo. I don't think
it's crappy or
> anything;
> I just prefer JS.
>
Similar Messages
-
Shockwave to Javascript - character encoding issue !
Hi !
I have resigned from sending messages from JavaScript to
Shockwave movie
as I have found all existing methods unreliable (at worst
scenario Flash
blocker is installed and using localConnection trick with
Flash gateway
fails).
But in the consequence, I have to send message (a search
string) from
Shockwave to JavaScript.
That seems easy with the following Lingo:
goToNetPage("javascript:void myJSfunction('" & aString
But the problem is with encoding possible non-ASCII
characters.
I presume the browser page is using charset=UTF-8.
Any idea how to properly encode 'aString' so it will preserve
non-ASCII
characters while being transfered to JavaScript?
It is really urgent!
Rgs,
Ziggi> I have resigned from sending messages from JavaScript to
Shockwave movie
I replied a little late to your earlier thread, but take a
look at
<
http://dasdeck.de/staff/valentin/lingo/dir_js/> -
If I have two identical symbols in Javascript they are not
equal as they would be in Lingo
ie.
//Javascript
var a = symbol( 'hello' );
var b = symbol( 'hello' );
put ( a == b );
// false
put ( a.toString() == b.toString() );
// true
-- Lingo
a = #hello
b = #hello
put a = b
-- 1
So my question is is this a bug or just the way Javascript
works?i suspect the reason for inequality is that the two symbols
are serate objects, each with it's own memory address. try this:
trace(typeof(a));
you'll get:
// object
toString type casts the symbol to it's string value.
this from the srcipting reference pdf:
Symbols
A symbol is a string or other value in Lingo that begins with
the pound (#) sign.
Symbols are user-defined constants. Comparisons using symbols
can usually be performed very
quickly, providing more efficient code.
For example, the first statement below runs more quickly than
the second statement:
-- Lingo syntax
userLevel = #novice
userLevel = "novice"
Symbols cannot contain spaces or punctuation.
In both Lingo and JavaScript syntax, convert a string to a
symbol by using the symbol() method.
-- Lingo syntax
x = symbol("novice") -- results in #novice
// JavaScript syntax
var x = symbol("novice"); // results in #novice
Convert a symbol back to a string by using the string()
function (Lingo) or the toString()
method (JavaScript syntax).
-- Lingo syntax
x = string(#novice) -- results in "novice"
// JavaScript syntax
var x = symbol("novice").toString(); // results in "novice"
In JavaScript syntax, you cannot compare symbols of the same
name to determine whether they
refer to the same symbol. To compare symbols of the same
name, you must first convert them to
strings by using the toString() method, and then perform the
comparison. -
Exit from Director with error code
Hi all!
How can I exit from director with specifyed error code by
using lingo or JavaScript syntax?
I want to catch its error code in batch file for example to
do something special.
Sample batch file I want to use:
myprojector.exe
if %ERRORLEVEL% == 10 goto GO_TO_SOMETHING_WRONG
But now, by default director quit with error code 0.
Thanks in advancelis0x90 wrote:
> How can I exit from director with specifyed error code
by using lingo
> or JavaScript syntax?
>
> I want to catch its error code in batch file for example
to do
> something special.
> Sample batch file I want to use:
>
> myprojector.exe
> if %ERRORLEVEL% == 10 goto GO_TO_SOMETHING_WRONG
>
> But now, by default director quit with error code 0.
I don't know of any way to do that, but you could get the
projector to
create a (zero byte) file if there's an error and in the
batch file check
for the existence of that file. (Not forgetting to delete
that file, if it
exists, when the projector starts.)
Andrew -
Resizing a movie in a window and it's sprites
I'm working on a kind-of slide show project. The 'show' runs
in a resizable window. The projector (created with Director v10)
has a lot of sprites (>60). Most of them should not be resized
and should stay at a fixed position (e.g. at the right margin),
other sprites should be resized (e.g. the 'slide'). It is more or
less as the Director authoring environment window where windows are
docked.
My question is if someone has a concept on how to deal with
this. I appreciate any help."ArmanIc" <[email protected]> wrote in
message
news:fjuiml$mj1$[email protected]..
> I'm working on a kind-of slide show project. The 'show'
runs in a
> resizable
> window. The projector (created with Director v10) has a
lot of
> sprites (>60).
> Most of them should not be resized and should stay at a
fixed
> position (e.g. at
> the right margin), other sprites should be resized (e.g.
the
> 'slide'). It is
> more or less as the Director authoring environment
window where
> windows are
> docked.
>
> My question is if someone has a concept on how to deal
with this. I
> appreciate
> any help.
Hi,
I have a set of behaviours for that.
They make a sprite keep its distance to the edge of the
stage, and you
can choose which edge (Left, Right, Top, Bottom). And then
there is
one other that sets a sprites position relative to the
centre.
I wrote them years ago for Dir 8, and are still in Lingo not
Javascript.
I could post them here, but they are not difficult to write,
and
besides, what is the fun? ;)
Basically it goes like this:
- store the starting position of the sprite or the offset to
its
reference (left edge, right edge...etc) on startmovie or
beginSprite
- detect the resizing of the window and send all sprites a
message
(sendAllSprites()).
- in the sprites' handler, calculate the new position of the
sprite
and put it there.
If you want to have them anyway, send me an email info
looping nl.
Good luck,
Richard. -
Hello, I am new to Director mx but i believe i'm up for the
task of doing what has to be done.
My problem: I need to load in and external cast that was made
a long time ago, load a couple of its members change some fonts and
save it back out. all with lingo or javascript.
So i started out by creating a new movie. then in the score i
add a new FrameScript it is located in the internal class
Then i make a new cast and call it dummy.
In the framescript in the internal class i do the following
var myCast = castLib("dummy");
myCast.FileName = "C:\path\editingcast.cst"; -
editingcast.cst has mor then 10 members.
trace(myCast.member.count);
halt();
what it prints out is strange. it prints out 1 which is the
number of members i have in my internal cast ie the script
currently running. I know its the script because when i ask to
print the first members name it prints out my script name.
when i run the code to see what the name of my cast file im
working on it prints out dummy. But the member that it prints out
isn't a part of the dummy cast.
Im very very confused.
Why is it not letting me access the newly linked cast?Do you actually have a castlib named "dummy"? If not make
one. Then
try your script again. -
I was wondering, if it is possible to pass Director
Javascript array object to Director linear list?
Are there any array search functions in Director Javascript
similar to: getOne, findPos etc.?
TIA
Yochai GaniThanks Sean
That was what I suspected of. Still, Javascript documentation
is so faint and vague I have hoped there are some undocumented
commands or features.
In a project I’m doing I’m reading a text file,
transform it into a list (array) and find a value in it (Locating
streets by city name).
Since I am a big fan of short and neat code, if I could just
combine lingo and Javascript I could make the entire operation with
3 lines of code without using any loop!
This could be done by using “split” and
“getOne”.
Still, it’s a pity, it would be really nice if it could
work.
Yochai Gani -
Hi Everyone ,
I want a Prompt Box which will be having one text box for the
user to enter the Name and two buttons which will be "Save "and
"Cancel" It is possible through the Javascript but I want to make
it through Lingo. I am not sure how to do this.
Any kind of help will be appreciated. Waiting for you
response....
Below is the code which is made in javascript. I want achieve
this thing through Lingo. Kindly tell if this is possible or else
please suggest a work around for it.
<html>
<head>
<title>Prompt Box</title>
<script>
function test()
var name=prompt("Please enter your name","")
document.write(name);
</script>
</head>
<body>
<input type="Submit" OnClick="test();"/>
</body>
</html>
Thanks and Regards
Atul Saxena> Buddy's baMsgBox does allow a few different options for
the button text,
> and baMsgBoxEx allows complete customization of the
message box
> including the font of the text on the buttons.
Yes, but it doesn't implement an #editText widget required to
get input
data from the user... -
Hi all,
I am working on a form that automatically fills itself out based on what the user selects using a dropdown box. I am encountering difficulties as, while I am proficient in Excel lingo, I know nothing about Java. I currently have a dropdown box where the user can select one of 4 choices. Based on that selection, I need another part of the form to fill in automatically. If anyone could assist me with this problem I would greatly appreciate it!
I would like the script to accomplish the following:
If the dropdown item selected reads "All Equity", I need the value to be 99.
If it reads "75-25", I need the value to be 75.
If it reads "50-50", I need the value to be 50.
If it reads "25-75", I need the value to be 25.
The dropdown menu is named "Portfolio Allocation" and the target/output blank is named "Equity Allocation".
Any help/tips would be great! Thanks!Since Arobat 6.0, the Windows version of Acorbat has had 2 programs that can create forms, Acrobat and LiveCycle Designer. Both programs can use JavaScript but the exact syntax can is different for field access.
Because of your field's nane it appears you are using Acorbat's AcroForms.
// get the value of field 'Portfolio Allocation'
var sResult = this.getField('Portfolio Allocation').value;
switch(sResult) {
case 'All Equity':
event.value = 99;
break;
case '75-25':
event.value = 75;
break;
case '50-50':
event.value = 50;
break;
case '25-75':
event.value = 25;
break;
default:
// all other answers
// clear field or other action
event.value = '';
break;
// or
// clear field
event.value = '';
// get the value of field 'Portfolio Allocation'
var sResult = this.getField('Portfolio Allocation').value
if(sResult == 'All Equity')
event.valaue = 99;
if(sResult == '75-25')
event.value = 75;
if(sReslult == "50-50")
event.value = 50;
if(sResult == '25-75')
event.value = 25; -
Is Director's Lingo faster than Flash's Actionscript?
Back in 2001, Gary Rosenzweig published "Comparing Lingo and
ActionScript" over at
http://director-online.com/buildArticle.php?id=973
At the time Lingo was 45x faster for a script that finds all
of the prime numbers between 1 and 1000. AS code and Lingo were
matched line for line in this script:
---------LINGO-------------
on prepareframe
startTime = the milliseconds
repeat with potentialPrime = 1 to 2000
isPrime = TRUE
repeat with i = 2 to potentialPrime-1
n = potentialPrime/i
if n*i = potentialPrime then
isPrime = FALSE
exit repeat
end if
end repeat
end repeat
alert "Total Time: "&(the milliseconds - startTime)
end
//--------------ACTIONSCRIPT----------------
test();
function test() {
startTime = getTimer()
for(potentialPrime=1;potentialPrime<=1000;potentialPrime++) {
isPrime = true;
for(i=2;i<potentialPrime;i++) {
n = int(potentialPrime/i);
if (n*i == potentialPrime) {
isPrime = false;
break;
trace("Total Time: "+(getTimer() - startTime))
Rerunning the same test today, comparing MX2004 Lingo with
AS2 in FlashPlayer 8, we find the gap significantly closed , but
still with Lingo being 6x faster.
Congrats to Flash for a relative 8x speed increase in 7
years. But imagine what we could be achieving with Lingo, if
Director had had the same amount of attention from Adobe/Macromedia
since 2001!
Anyway, just thought I'd give you some good news. :)I was also curious about Javascript in Director, so I ran a
JS version of the same script:
function test() {
startTime = _system.milliseconds
for(potentialPrime=1;potentialPrime<=1000;potentialPrime++) {
isPrime = true;
for(i=2;i<potentialPrime;i++) {
n = parseInt(potentialPrime/i);
if (n*i == potentialPrime) {
isPrime = false;
break;
trace("Total Time: "+(_system.milliseconds - startTime))
test();
Well, it surprised me. And disappointed me too. This came in
at 5x slower than the same script in Lingo! -
dear all ...
can help me?..
I make glossary with RTF text because on RTF Text is easy to change content but can help me to make search text or word on RTF text with lingo..?
ThankyouChanging the BG colour of a chunk of text is not easy. It can be done with some imaging-lingo hoop-jumping, or by having a pool of shape sprites that can be dynamically allocated, sized and positioned.
Place the following in a JavaScript typed #movie script:
function jsSearch (aString, aMatch) {
var aPattern = new RegExp(aMatch, "gi");
var found;
var results = list();
while((found = aPattern.exec(aString)) != null) {
results.append(found.index);
return results;
and this in a "regular" Lingo #movie script:
on mHighlightMatches aMember, aString
-- error check inputs
if ilk(aMember, #member) = 0 then
aMember = member(aMember)
if ilk(aMember, #member) = 0 then
exit
end if
end if
if stringP(aString) = 0 then aString = string(aString)
if stringP(aString) = 0 then exit
-- will only work with #text nmembers
if (aMember.type <> #text) then exit
aMember.color = rgb(0, 0, 0)
len = length(aString)
lMatchPositions = jsSearch(aMember.text, aString)
if count(lMatchPositions) = 0 then
alert "Search text not found"
else
repeat with aStart in lMatchPositions
aMember.char[aStart..(aStart + len)].color = rgb(255, 255, 0)
end repeat
end if
end
and now your button script might look like:
on mouseUp me
mHightlightMatches(member("text2"), member("text1").text)
end -
Javascript - Access sub-properties of lists
I've got a very basic problem: I want to assign a color to a
line inside a field.
Basically, this is all that's needed for doing this in Lingo:
member.line [ i ] .color=color(255.128.128);
However, a requirement for my studies is that I have to do it
in Javascript and the dot notation doesn't work there... instead
you use setProp... so by normal JS standards this should work:
member.getProp("line",i).setProp("color",color(255.128.128));
However, for some reason that I'm 100% unable to understand
member.getProp("line",i) doesn't return an object... instead it
returns a string!?!
So I need a way to access nested properties directly via
setprop... I've tried this:
member.setProp("line["+_mouse.mouseLine+"].color",color(255,0,0));
In the hope that Director would parse the
"line["+_mouse.mouseLine+"].color" bit to get to the correct
property... but sadly it doesn't.
Any help would be VERY welcome :)Found the solution: You've got to use getPropRef:
member.getProp("line",i).setPropRef("color",color(255.128.128));
What I find really disturbing is that this is probably the
110th method that I've found in a few forums, but not in the
documentation... it's simply not listed and even a fulltext search
does only provide a single half-sane result: "Choosing between
Javascript and Lingo Syntax", the rest are functions that have
nothing to do with properties, they just need it for their
examples.
I'm sorry, but you guys really have to get your act together
documentation-wise! -
A good wishlist script (javascript or asp)
Anyone have a favorite (easy to use, hopefully)
javascript-based wish
list script?
My eyes are going buggy searching for one via google and I
thought I'd
tap into the expertise here for recommendations.
TIA!
DonnaMost books on JavaScript are geared for its use in web development, and deal with the DOM... Document Object Model. In this case JavaScript is used for programmatic interaction with web page elements such as form elements (buttons, text fields, etc), images, and those kinds of things. The DOM in Director is the Director Object Model. JavaScript in Director is obviously used to programmatically control sprites, cast members and such, not web elements. The content in almost all books and web sites focuses on the wrong DOM. Usually only just the beginning of these learning materials cover core JavaScript.
IMHO the best source for learning JavaScript is JavaScript: The Definitive Guide by David Flanagan. It is DOM (wrong one) heavy but also has extensive core JavaScript info.
The specification for JavaScript, or more properly ECMAScript (ECMA-262), can be found here: http://www.ecma-international.org/publications/standards/Ecma-262.htm
The ECMA reference is dry and technical but invaluable.
Two good JavaScript learning and reference sites are wwwschools.com and javascriptkit.com. Again, these are big on the Document Object Model.
Tom Higgins put together a real good reference page for the Director Object Model (right DOM) and fortunately it’s still online: http://poppy.macromedia.com/~thiggins/articles/dom/DOM.htm
I’ve found it to be a great resource as it is both a JavaScript and Lingo reference.
So long story short, IMO the best book for JavaScript is David Flanagan’s and the best DOM reference for Director is the one Tom Higgins put together.
HTH
-
The state of JavaScript support in Director 11
Hi! I asked this question in several places without any
meaningful feedback, maybe someone around here will shed some more
light on this ;) Ok, here it goes:
It looks that Lingo is the most natural choice for many
Director developers. Even though I have nothing against Lingo, I
prefer using JavaScript to it due to my personal reasons. And I
wonder what's the state of JavaScript support in the new Director?
To be honest, I've always had a feeling that JavaScript
script was added into Director MX in the last minute just before
the release ;) Awkward getPropRef(..), absence of some important
methods available in
Lingo(e.g member(0).model("foo")), fatal errors on the every
tiny typo when working with 3d stuff, etc.
Has anything changed in the new Director? And if no, does it
really make sense to use JavaScript in Director at all?
Can someone around tell me of any serious game(like Maid
Marian) using JavaScript instead of Lingo? How fast JavaScript
virtual machine compared to Lingo? I also have a very strong
suspicion that JavaScript can be a cause of memory leaks when used
improperly, especially in case of closures, any tips on this?
Thanks in advance.I prefer JavaScript to Lingo as well, mainly because I
learned scripting/programming in
C++/Java/C#/ActionScript/JavaScript. I’ve been using
JavaScript syntax exclusively since MX 2004, and while there are
things you have to work around, like not being able to access
models by name, I’ve had great success with it.
I prefer JavaScript syntax OOP in Director to Lingo Parent
scripts. There are some buggy things to deal with; for instance
I’ve had issues with “static” members
mysteriously becoming undefined, but nothing I’ve not been
able to work around. I use a getMemberByName(memberName,
memberType, w3dMember) function to get around the
“can’t get model/texture/shader etc. by name”
issue. Try/catch has been a huge help. I’ve got nothing
against Lingo, and hope future versions of Director continue to
support it because so many long time users like it. However, as I
said, I’ve not used it for years.
I was lucky enough to get a Director 11 Beta 1.0 CD-ROM
because an associate recommended me for it to Adobe. I wasn’t
a true Beta tester per se, and wasn’t asked to abide by any
NDA. In fact, my inquiries into what my
responsibilities/restrictions were to be went unanswered.
That being said, I’m afraid I can’t offer much to
this discussion; I installed the Beta on my laptop (Vista) the day
I got it but had vacation for two weeks a week after that. The Beta
version was essentially a 30 day trial and while I told myself
“I’ll check it out while on vacation” my wife had
other ideas. I did see that there was a JavaScript dictionary that
mirrored the Lingo dictionary in the script editor, but that there
was no color hinting for JavaScript syntax. In fact that was
pointed out in the documentation. I can’t say if this is
still true in the final version. Everything I tried (author time
and runtime) worked well in Vista, whereas I’ve had a few
problems with MX 2004 and Vista.
I’m unaware of any tweaks to the SpiderMonkey engine or
its implementation in Director, and don’t feel my limited use
of the Beta qualifies me as a reliable source of info on the
matter, especially since I wasn’t able to really run it
through the ringer. I can say that during my limited
experimentation I didn’t run into any issues and that
everything ran smooth… no “a fatal error has
occurred” messages like I too often get now.
On the whole I’m feeling very positive about not only
this release but Director’s immediate future. I’m
getting the durn thing the first week it’s out. -
Pass data between AS and Lingo
Hi
We have an Arabic educational application in Director 11.5, published originally asprojector for desktop use. Since Director don't support “right to left” languages, the application uses an ActivX component to call external encoded html and load it into a textarea container, in this way the Arabic language can be written and redden.
since ActiveX is not sockwave-safe and cannot be used , im using swf as an input textarea. it seems ok ( i dont read Arabic so i cant tell if its correct), the important thing for this stage is that i can write text and no errors comes from the shockwave player.
The main problem:
the words been typed in the swf , should be sent to the the Lingo script in Director, for example there is a "speed typing test " that check if all the typed words are correct.
in the original the application uses:
sprite(120).navigate(the moviePath & "assets\t.html")
to load the html into the textarea and uses and:
on hideQuitDialog me
if the frame > 45 then
mySprite.locV = 485
mySprite.puppet = 0
mySprite.navigate("Javascript: focusText()")
end if
end
to get some javascript from the html.
my question is how to pass the swf input data to Lingo? what code should i use, either in Flash AC3 or in Lingo in Director to make this happand?
appreciate you time
Tx
ShayHi,
The problem was that when populating and reading the custom controller, I had to add GLOBAL. in front of the custom controller name. Like this: 'GLOBAL.ZKBT116QH_SRVQ/CuCoOrders'
Thank you,
Andra.
Maybe you are looking for
-
Mail crashes at start-up after update to 10.8.3
Help!! After updating to 10.8.3 my Mail application crashes at start-up. This dialog box comes up and no matter which I choose, the program crashes. I tried trashing V2 folder, deleting and reinstating mail accounts, prefs, and reinstalling 10.8.3 fr
-
Corrupt Boot disc - how do I boot from OSX disc to run Repair Disc?
I have just run Verify Disc and it has identified problems which requires me to boot from my OSX disc and run Repair disc. I think I do this by switching on while holding down C....is that right? ALSO I can only find my Leopard boot discs and I am cu
-
if they created a new web program, taking away support adobe firework, there are tools that are necessary for the web: Create a rectangular slice based on a selected object Add Filters button in the Properties panel. Photoshop Live Effects Tools and
-
Does ayone know anything about the acclaimed Intel imacs?
Apperently there is a new intel imac coming soon. The thing is I want an imac for christmas but I am not sure if its worth waiting for this new intel one. Plus if the new intel imacs would work with frutiy loops (a windows music programe). Cheers Sam
-
Can't close multiple open documents
I have Lion, and all the iWork updates. Try as I might I cannout seem to get Pages to STOP opening the last 10 documents I was working on. I have tried the System Preferences for Mission Control and rebooted and UNselecting "open with windows" or wha