Hi Daniel Try protecting the unicode string when transferring between the two flash sprites using JS Syntax.
escape() the string in Flash movie 1, pass it to JS Syntax, unescape the string in JS Syntax and manipulate the string, escape it, pass into Flash Movie 2, unescape it and put it into the field. For example, I took a Japenese UTF-16 encoded XML file that contained some unknown text (I can't read Japenese). I loaded in Flash movie 1, put it in a text field without parsing using the onData method of the XML object in Flash. Created a function on _level0 that would return me the unicode text of the field, escaping it for safe transport through Director's death grip on the Flash asset. Recomposed it inside of JS Sytnax using unescape, manipulated the string in JS Syntax by appending a bunch of mu characters using \00b5. Then escaped the string, passed it into Flash sprite 2 by calling a function that took the test string, unescaped it and placed its unescaped content into the field of Flash sprite 2. All the Japenese characters were perfectly preserved and the second Flash sprites field contained a row of mu characters at the bottom. I can email you a zipped file of my test if you desire.. it ain't fancy, actually its downright ugly. But it shows that JS Syntax is indeed unicode safe under the hood. You just have to get around Lingo's mangling of the string using escape. JS Syntax does not directly manipulate a Flash sprite, it still passes through MOA and in effect Lingo on its way in and out of the Flash. Sincerely Mark R. Jonkman > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] Behalf Of Daniel Plaenitz > Sent: Thursday, February 19, 2004 5:52 PM > To: [EMAIL PROTECTED] > Subject: <lingo-l> unicode through the backdoor? > > > > There had been some hints that with javascript in director there might > possibly be a chance to use unicode in director. > > Thomas Higgins, 7.1.04: > > Lingo strings do not support Unicode so that's why you're likely having > trouble using Flash assets to render your unicode strings. Once Lingo > touches 'em you're hosed... But wait... There's more! You'll have to wait > for Christmas though, sorry! > > > Mark Jonkman, 12.2.04: > > JS is unicode under the hood, so you get some "quasy" unicode handling > (until you go to display - but if your display is a Flash sprite, > you might > just get away with the unicode remaining intact). > > > My plan went along similar lines. Translate my text manager to > js, employ a > bunch of flash sprites for output and input ( with the > commonplayer set for > minimal performance hit ) and voila, localizing projects to more > demanding > languages like thai, farsi, etc. would be much less intimidating... > > Well, as of now the results look disappointing. In fact I have not found > any indication that director's js supports unicode at all. > > > What follows is a longish tale of failure and a lame solution to at least > tunnel unicode through directors realm. > > > I took my examples from the "anyone can be provincial!" page at > <http://www.trigeminal.com/samples/provincial.html> and my first try was > copy and paste. I didn't really expect the message window in javascript > mode (all these experiments were javascript only) to display > unicode and it > didn't. > > So I read the file with fileIO to a var and passed that via > sendsprite() to > a flash sprite for display. All the "non-western" characters showed as > question marks, exactly as they did in the messWin. The next attempt went > via _globals, same result. > > OTOH, reading the file to a var in flash and then feeding it to the very > same function for display worked fine and showed the text intact. My > suspicion fell on the fileIO xtra. > > Anyway, since I now had the data intact in that flash sprite I > proceeded by > pulling them up to directors javascript and then pass them to another > flashsprite. The commonplayer brought to many crashes. So I tried it like > > function test() { > dsp=sprite(5); > dsq=sprite(6); > > dtxt = dsp._root.sometext; > dsq.setText( dtxt ); > } > > and this failed too, Question marks. > > What about passing unicode strings packaged in arrays? js can access > actionscript arrays, but not the other way. Similar, js accessing > one flash > sprites array and then just passing it to the other flash sprite won't do > since its out of scope for the second flash. Therefore each flash sprite > should supply its own array and js has to copy the data: > > > function test2() { > > dsp=sprite(5); > dsq=sprite(6); > > arrdsq = dsq.newObject( "Array" ); > > arrdsq.push ( dsp.getPackagedData().pop() ); > > dsq.setPackagedData( arrdsq ); > > } > > Question marks. This about settles it. Both push() and pop() are > actionscript methods, js only makes the two objects meet and passes the > value. Even with javascript it appears that director strips > unicode strings > on assignment. > > > Ok, And after this long and disappointing narration here comes the only > safe channel for unicode data from one flash sprite to another which I > could make work: as an array of integers. > > The flashs have these functions: > > > > function getArrOfCharCodes(aStr){ > arr = new Array(); > for (i=0;i<aStr.length;i++){ > arr.push(aStr.charCodeAt(i)); > } > return arr > } > > function setArrOfCharCodes(arr) { > var aStr=""; > for (i=0;i<arr.length;i++){ > aStr += String.fromCharCode(arr[i]); > } > setText(aStr); > } > > function setText(aStr) { > myTextInstance.text = aStr; > } > > > and in director : > > > > > function passData(){ > > dsp=sprite(5); > dsq=sprite(6); > > // arrsometext has been prepared by getArrOfCharCodes(aStr) > arr = dsp._root.arrsometext; > arrdsq = dsq.newObject( "Array" ); > > // werte rueberheben > for (i=0;i<arr.length;i++) { > arrdsq.push( arr[i] ); > } > > dsq.setArrOfCharCodes( arrdsq ); > > } > > > Hmm. I just hope someone finds a better way. > > > daniel plaenitz > > > > [To remove yourself from this list, or to change to digest mode, > go to http://www.penworks.com/lingo-l.cgi To post messages to > the list, email [EMAIL PROTECTED] (Problems, email > [EMAIL PROTECTED]). Lingo-L is for learning and helping > with programming Lingo. Thanks!] > [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]). Lingo-L is for learning and helping with programming Lingo. Thanks!]
