30 Replies Latest reply on Sep 28, 2006 10:48 AM by Peter Lorent

    change font..

    jonnybennett Level 1

      myTextFormat=new TextFormat();
      myTextFormat.align='right';

      myButton.onRelease=function(){
      textBox.setTextFormat(myTextFormat);}

      this works... however when instead I try and change the font face instead....

      myTextFormat=new TextFormat();
      myTextFormat.font="Arial";

      myButton.onRelease=function(){
      textBox.setTextFormat(myTextFormat);}


      This does not change the text font to arial. Instead the text dissapears. Any ideas?
      I have embedded the fonts i am using.
      Thanks to any responders. J
        • 1. Re: change font
          Peter Lorent Level 2
          >>I have embedded the fonts i am using.
          Don't for the fonts that are installed in your system.
          • 2. change font
            jonnybennett Level 1
            Thanks, but as I understand it I have to embed the fonts, as I am also changing the alpha of the font, which appears to only be possible if the font is embedded... however this still doesn't explain why I can not change the font. Any ideas?
            • 3. Re: change font
              Juankpro Level 2
              The font can only be transparent when embedded. Making an application that allows you to change to any font and to give it an alpha value can end up being excesively heavy. Because you will need to embed all the fonts or at least a lot of them. So it is not a good idea. Just use not embedded fonts and don't change its _alpha channel.
              • 4. Re: change font
                Juankpro Level 2
                How are you embedding the font. By the way?
                • 5. Re: change font
                  jonnybennett Level 1
                  JuanKpro, thanks for the message. When I have a textfield highlighted, i go to properties and click the embedd button, then I select the characters i wanna embed... i think this is the right way? Anyway we are getting off the point... I really want to know why wont the font change using the following actionscript?

                  myTextFormat=new TextFormat();
                  myTextFormat.font="Arial";

                  myButton.onRelease=function(){
                  textBox.setTextFormat(myTextFormat);}
                  • 6. Re: change font
                    TimSymons Level 1
                    I just tried this and it works. Make sure that you set the linkage name for your font to "Arial" or it won't work.

                    Tim
                    • 7. Re: change font... kglad I bet you know???
                      kglad Adobe Community Professional & MVP
                      to embed a font for use with actionscript you must click on the upper right of your library panel, click new font, pick the font you want to use, give it a name that you can remember and click ok.

                      your font is now added to your library. right click on it, click linkage, tick export for actionscript and give it a linkage id. now, use that linkage id to define the font property of your textformat object.
                      • 8. Re: change font... kglad I bet you know???
                        Juankpro Level 2
                        We are not getting of the point. Because this behavior is normal. Is you embed Times New Roman for example to a TextField then that textField can only show that font. I fyou change it to Arial, because the Arial font is not embedded, it will not show any character.
                        • 9. Re: change font... kglad I bet you know???
                          Juankpro Level 2
                          To embed many fonts you need to do one of the following procedures:

                          1) Create TextFields, one for each font you want to use and place them off stage, then embed all the characters you want. Note that flash recognizes Arial, and Arial with bold as two different fonts. Then you can use those fonts in any other TextField as being embedded.

                          2) Create font symbols in the library for all the fonts you want to use.
                          • 10. change font..
                            Peter Lorent Level 2
                            I've uploaded an example for you: (let me know when you have downloaded the file so I can remove the link)
                            • 11. Re: change font... kglad I bet you know???
                              jonnybennett Level 1
                              LuigiL, Firstly thank you very much for the amount of effort you have gone to help, it is much apprecuiated. I have downloaded your link, but I am getting the same results as I was with mine, when I press a button to change the text it dissapears. Please note that I was embedding my fonts in the same way as you. However when I tried to embed the fonts in the way kglad has suggested it works fine. So i think the answer is as i think juankpro is also poining out that there are diff ways to embedd fonts, and for what i need i need to do as kglad has suggested. So thanks alot to you all for your help. Jonnie
                              • 12. Re: change font... kglad I bet you know???
                                Peter Lorent Level 2
                                >>when I press a button to change the text it disappears
                                I tried to replicate that situation but I can't. Only when I don't embed the fonts. Oh well, the problem is solved.
                                • 13. Re: change font..
                                  kglad Adobe Community Professional & MVP
                                  jb had the problem because by pressing the button he was trying to embed a font with a linkage id ("Arial") that didn't exist.
                                  • 14. Re: change font..
                                    Peter Lorent Level 2
                                    No, he was embedding the fonts using text fields and that should work too. He tried the file I uploaded - which works on my side - but the problem persisted on his side. Don't get that.
                                    • 15. Re: change font..
                                      kglad Adobe Community Professional & MVP
                                      embedding a font in a textfield won't allow you to use actionscript to change to a different font. if you try you'll have the same problem as jb and your font will disappear.

                                      i don't know what was in your file but i suspect he added a button that tried to change the font and the text disappeared.
                                      • 16. Re: change font..
                                        Peter Lorent Level 2
                                        >>embedding a font in a textfield won't allow you to use actionscript to change to a different font. if you try you'll have the same problem as jb and your font will disappear.

                                        Not a problem. The file I uploaded used text fields to embed the fonts and I used actionscript on a button to change the font. I'll try to replicate the disappearing of the text. Still want to know what caused it (him using my - working - file that is).
                                        • 17. Re: change font..
                                          kglad Adobe Community Professional & MVP
                                          if you had more than one textfield, each with different fonts embedded then you can use actionscript to change the fonts of each textfield to the font of the other textfield.
                                          • 18. Re: change font..
                                            Peter Lorent Level 2
                                            Yep. So why does his text disappears? Well, I'll try to figure it out but his problem is solved so there's no hurry. Have a nice sunday.
                                            • 19. Re: change font..
                                              kglad Adobe Community Professional & MVP
                                              as long as the bears win, it'll be a good sunday... :)
                                              • 20. Re: change font..
                                                Peter Lorent Level 2
                                                That's like Ajax Amsterdam for me...
                                                • 21. Re: change font..
                                                  kglad Adobe Community Professional & MVP
                                                  phew.
                                                  • 22. Re: change font..
                                                    crazyjoemilan Level 2
                                                    yeah, what happened? Where'd he get that arm?
                                                    • 23. Re: change font..
                                                      kglad Adobe Community Professional & MVP
                                                      rex was born with a golden arm... . GO BEARS!!!
                                                      • 24. Re: change font..
                                                        Peter Lorent Level 2
                                                        phew.
                                                        • 25. Re: change font..
                                                          kglad Adobe Community Professional & MVP
                                                          phew??? they haven't played ik, yet. have they???

                                                          man, if you know the result of that match we could be making some big bucks.

                                                          p.s. it's 5:40 am in amsterdam.
                                                          • 26. Re: change font..
                                                            Peter Lorent Level 2
                                                            It's 6.11 PM in Amsterdam at the moment and time to eat (fish to be exactly). Thought they played last Sunday or did I misunderstand that? Oh well, hope they win.
                                                            • 27. Re: change font..
                                                              kglad Adobe Community Professional & MVP
                                                              their 2-0 win over nec nijmegen is from last week.

                                                              i thought you were saying phew because they had just won a close match against ik start. but from what i know, that match is going to be played a few hours from now.
                                                              • 28. Re: change font..
                                                                Peter Lorent Level 2
                                                                The fish was good! Oh man, my English... I totally missed the meaning of 'phew'. I thought with phew you were saying 'hey man, what's Ajax Amsterdam compared to the Bears' - in a funny way. So, my phew followed on your post concerning the GO BEARS!!! (what's that compared to Ajax Amsterdam - in a funny way of course). Well, took me some time... but now I get it. In Dutch there is a word close to 'phew'. Well, my bad.

                                                                IK lost last weekend in the Norwegian competition and seem to be in a dip. Two weeks ago Ajax already won 2-5 in Norway so tonight in the Arena (which is a big stadium compared to the Norwegian stadium) we should be able to stay in the UEFA cup. But, Ajax is not performing well so I don't know... 8.45 tonight the game begins.
                                                                • 29. Re: change font..
                                                                  kglad Adobe Community Professional & MVP
                                                                  lol. actually, if i'd said "pfft", your initial impression would have accurate.

                                                                  as you probably now know, i said phew because the bears had just pulled out a close win in the last 2 minutes of the game.

                                                                  and your english is so good it never occurred to me that it might not be your first language. in fact, your command of english is significantly better than most people born in the u.s.
                                                                  • 30. Re: change font..
                                                                    Peter Lorent Level 2
                                                                    Well, in Dutch we say pfff but in 'slang' it comes close to phew. I guess you know but here - unlike in many European countries - tv is not translated to the native language but instead we have subtitles (it's really funny to watch an episode of 'Lost' in Spanish). As a kid you already hear a lot of English and I think that has its influence. All the books I have on programming and design are in English. And my kids are on an international school where most of the lessons are in English so we speak a lot of English at home. When I read a book for fun, I read it in English. Among our friends are some that speak English. When I go abroad for work, yep, English. And somehow, the word phew missed in my vocabulary!!! Never to old to learn!