Hi all,
I'm wondering if anyone has figured out why after normally about 300-500 lines of JavaScript in a Script Object, sometimes the functions near the end are no longer recognized by the XFA processor when referenced ("TypeError: Scripts.myFunction is not a function").
When reordered, further up the script object, they work as intended. The line at which it no longer recognizes functions also isn't always the same and I have worked with some script objects that have over 800 lines with all the functions still working.
I've tested in Designer 9 and 10, Reader 8 9 and 10.
Please at least let me know I'm not the only one. I knew of one other developer that had come across the same issue.
Kyle
Solved! Go to Solution.
Views
Replies
Total Likes
I've never had a problem with large scripts, even with 1000 or more lines.
Have you done a JSLint test of your scripts?
Dirty syntax can always have some side effects.
http://blogs.adobe.com/formfeed/2010/09/javascript-lint-check-in-designer.html
Views
Replies
Total Likes
I've never had a problem with large scripts, even with 1000 or more lines.
Have you done a JSLint test of your scripts?
Dirty syntax can always have some side effects.
http://blogs.adobe.com/formfeed/2010/09/javascript-lint-check-in-designer.html
Views
Replies
Total Likes
Thanks radzmar!
JSLint didn't find anything but it set me on the path towards looking for syntax errors. I deleted code in the script object line by line until I narrowed it down.
Turns out it is Regular Expression literals, in particular trying to escape (\) the metacharacters ($.{}[] etc).
For example, var reg = /\}/; should technically match any right-handed curly brace, which in fact it does! The function that it is in works perfectly but every function written below it is not recognized by the XFA processor. Just out of curiousity I tried reg = /\{\}/; which matches {} and all the functions below now are recognized. It seams as though, even though using the escape character is allowed in core JavaScript, the processor sees it as a syntax error because it's not terminated.
Anyways, the easy fix is of course using the RegExp constructor var reg = new RegExp("\\}"); but I'll miss the confidence I had using Regular Expression literals.
Thanks again for the nudge in the right direction.
Kyle
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies