13 Replies Latest reply on May 26, 2009 4:10 PM by fazstp

    degree symbol displays as infinity on Mac.

    kar13 Level 1

      Hi,

      I have a frustrating issue that I can't solve. Adobe won't help me because Director MX 2004 is "beyond it's product support life cycle."

      Hopefully someone here can help me out...

       

      ·         I’m using Director MX 2004.

      ·         I have scrolling text boxes that contain the degree symbol. I’m using the font Arial. Once I shock the file and view it on a Mac, in Safari or FF, the degree symbol displays as the infinity symbol instead. On the PC it looks like a degree symbol, as expected.

      ·         I’ve tried using the ASCII character (alt 0176) as well as the Symbol font character.

      ·         I’ve tried setting the “save bitmap” property of the text box to both true and false. Neither work.

      ·         This is only happening with text boxes. Text fields display the degree symbol just fine on Mac and PC. However, due to the very limited formatting capabilities of the text field, I am unable to just use text fields instead of text boxes.

      ·         How do I get special characters (degree symbol, bullet) to display correctly cross-platform in a text box??

       

      Thanks for any help.

       

      -Karen

        • 1. Re: degree symbol displays as infinity on Mac.
          Sean_Wilson Adobe Community Professional

          You could research which keyCode corresponds to the degree symbol on Mac and then use the beginSprite event in a behavior attached to your #text sprites to scan for chars with a particular keyCode and replace them with the correct one. You could even use a JavaScript regular expression if speed is an issue.

          1 person found this helpful
          • 2. Re: degree symbol displays as infinity on Mac.
            fazstp Level 2

            In a text field on my Mac with Arial font the degree symbol is numToChar( 188 )

            1 person found this helpful
            • 3. Re: degree symbol displays as infinity on Mac.
              kar13 Level 1

              Sean,

              Thanks for responding. How would that work exactly? Would it only replace the character on Mac OS systems? I'd have to include some code to determine the OS? I'm not a programmer, so any additional input on this sprite behavior would be great. Thanks.

              • 4. Re: degree symbol displays as infinity on Mac.
                kar13 Level 1

                fazstp,

                Thanks for the info. Hopefully I can use it in conjuction with Sean's idea. 

                • 5. Re: degree symbol displays as infinity on Mac.
                  Chunick Level 3

                  The ASCII Character Set is only the same between PC and Mac up to 128: http://img.brothersoft.com/screenshots/softimage/a/ascii_table-84123-1.jpeg

                   

                  Above 128 it's anyone's game... this is called the Extended Character Set: http://academic.evergreen.edu/projects/biophysics/technotes/program/ascii_ext-mac.htm

                  • 6. Re: degree symbol displays as infinity on Mac.
                    fazstp Level 2

                    on SetDegreeChar

                      win_char = numToChar( 176 )

                      mac_char = numToChar( 188 )

                     

                      if ( the platform contains "Mac" ) then

                        SearchAndReplace( member( "my text field" ), win_char, mac_char )

                       

                      else

                        SearchAndReplace( member( "my text field" ), mac_char, win_char )

                      end if

                     

                    end SetDegreeChar

                     

                    on SearchAndReplace text_member, search_string, replace_string

                      if NOT ( ilk( text_member ) = #member ) then

                        return FALSE

                      end if

                     

                      if NOT ( text_member.type = #text ) then

                        return FALSE

                      end if

                     

                      if NOT stringP( search_string ) AND ( search_string <> EMPTY ) then

                        return FALSE

                      end if

                     

                      if NOT stringP( replace_string ) then

                        return FALSE

                      end if

                     

                      start_char = 1

                     

                      repeat while ( text_member.char[start_char..text_member.char.count] contains search_string )

                        char_num = offset( search_string, text_member.char[start_char..text_member.char.count] )

                       

                        if NOT ( char_num ) then

                          exit repeat

                        end if

                       

                        start_chunk = start_char + char_num - 1

                        end_chunk = start_chunk + search_string.char.count - 1

                       

                        put replace_string into text_member.char[start_chunk..end_chunk]

                       

                        start_char = start_chunk + replace_string.char.count

                      end repeat

                     

                      return TRUE

                     

                    end SearchAndReplace

                    • 7. Re: degree symbol displays as infinity on Mac.
                      kar13 Level 1

                      fazstp,

                      Oh my gosh! Thanks. I would have never been able to write that code! I can't wait to test it out when I get to work tomorrow!

                       

                      • 8. Re: degree symbol displays as infinity on Mac.
                        Sean_Wilson Adobe Community Professional

                        Stephen already provided a code solution, but here's an alternative:

                         

                        -- scriptText of a scriptSyntax = #lingo movieScript member:
                        
                        on SetDegreeChar aMember
                        
                          -- error check input
                          if ilk(aMember, #member) = 0 then return
                          if [#text, #field].getPos(aMember.type) = 0 then return
                        
                          win_char = numToChar( 176 )
                          mac_char = numToChar( 188 )
                        
                          tText = aMember.text
                          if offset( the platform, "Mac" ) then
                            newText = jsReplace( tText, win_char, mac_char )
                          else
                            newText = jsReplace( tText, mac_char, win_char )
                          end if
                        
                          if ( newText <> tText ) then aMember.text = newText
                        
                        end SetDegreeChar
                        
                        
                        // scriptText of a scriptSyntax = #JavaScript movieScript member:
                        function jsReplace(inStr, strFind, strReplace){
                          // error check input
                          if(typeof(inStr)      != "string") { return inStr; }
                          if(typeof(strFind)    != "string") { return inStr; }
                          if(typeof(strReplace) != "string") { return inStr; }
                          // search-and-replace
                          re = new RegExp(strFind, "g");
                          return inStr.replace(re, strReplace);
                        }
                        
                        • 9. Re: degree symbol displays as infinity on Mac.
                          fazstp Level 2

                          Sean_Wilson wrote:

                           

                          Stephen already provided a code solution, but here's an alternative:

                           

                          I wasn't sure if text formatting needed to be maintained so I opted to replace the chars within the member. If that isn't an issue then you will probably find Sean's solution to be quicker.

                          • 10. Re: degree symbol displays as infinity on Mac.
                            kar13 Level 1

                            fazstp,

                            I tried using your code but it doesn't seem to be having any effect. Please excuse my ignorance; I'm sure I'm doing something wrong....

                             

                            I copy/pasted your code into a new script window. Should this be a #score, #movie, or #parent  scriptType?

                            Do I apply this directly to each textbox item? Do I apply it to a frame in the script channel? Do I put it in frame 1's script channel so it affects the entire movie?

                             

                            Also, on PC the degree symbol is Alt0176. Do I need that 0 in the code you provided? Your code says numToChar( 176 )

                             

                            Your code references "my text field". I'm trying to alter text Boxes, not fields. Does that matter?

                             

                            Each of my text boxes already have individual member names. Is there a way to have this code affect whatever textbox it's applied to, rather than specifying a member name?  Text member of me .... or something like that?

                             

                            Sorry if these are rudimentary questions.

                            Thanks for your help.

                            -Karen

                            • 11. Re: degree symbol displays as infinity on Mac.
                              kar13 Level 1

                              Hi Sean,

                              I tried implementing your code, but Director is giving me script errors.

                               

                              It doesn't like this line:   // scriptText of a scriptSyntax = #JavaScript movieScript member:

                               

                              I assumed the double hash was intended as a commented line, so I commented out the // lines in Director to test it.

                              Then I got a script error (Handler definition expected) on this line:    function jsReplace(inStr, strFind, strReplace){

                               

                               

                              I'm sure it's an error on my part.

                              Any idea what I'm doing wrong?

                               

                              Would I apply this script to the individual text items in the score? Do I put it in the upper script channel somewhere?

                               

                              Thanks for all your help.

                              -Karen

                              • 12. Re: degree symbol displays as infinity on Mac.
                                Sean_Wilson Adobe Community Professional
                                It doesn't like this line:   // scriptText of a scriptSyntax = #JavaScript movieScript member:

                                Like the comment says, the scriptText following should be in a movie script whose scriptSyntax is set to JavaScript. Do you understand what I mean by "movie script" and "JavaScript scriptSyntax"? It sounds to me like you have tried to compile it into a Lingo script.

                                • 13. Re: degree symbol displays as infinity on Mac.
                                  fazstp Level 2

                                  You could use this version in a behaviour (#score type) applied to the text fields. It should format the degree char on beginSprite.

                                   

                                   

                                  on beginSprite me

                                    SetDegreeChar( me )

                                   

                                  end beginSprite

                                   

                                   

                                  on SetDegreeChar me

                                    win_char = numToChar( 176 )

                                    mac_char = numToChar( 188 )

                                   

                                    if ( the platform contains "Mac" ) then

                                      SearchAndReplace( me, sprite( me.spriteNum ).member, win_char, mac_char )

                                   

                                    else

                                      SearchAndReplace( me, sprite( me.spriteNum ).member, mac_char, win_char )

                                    end if

                                   

                                  end SetDegreeChar

                                   

                                   

                                  on SearchAndReplace me, text_member, search_string, replace_string

                                    if NOT ( ilk( text_member ) = #member ) then

                                      return FALSE

                                    end if

                                   

                                    if NOT ( text_member.type = #text ) then

                                      return FALSE

                                    end if

                                   

                                    if NOT stringP( search_string ) AND ( search_string <> EMPTY ) then

                                      return FALSE

                                    end if

                                   

                                    if NOT stringP( replace_string ) then

                                      return FALSE

                                    end if

                                   

                                    start_char = 1

                                   

                                    repeat while ( text_member.char[start_char..text_member.char.count] contains search_string )

                                      char_num = offset( search_string, text_member.char[start_char..text_member.char.count] )

                                   

                                      if NOT ( char_num ) then

                                        exit repeat

                                      end if

                                   

                                      start_chunk = start_char + char_num - 1

                                      end_chunk = start_chunk + search_string.char.count - 1

                                   

                                      put replace_string into text_member.char[start_chunk..end_chunk]

                                   

                                      start_char = start_chunk + replace_string.char.count

                                    end repeat

                                   

                                    return TRUE

                                   

                                  end SearchAndReplace