1 2 Previous Next 44 Replies Latest reply on Apr 11, 2009 2:22 PM by ergo_eleven

    Rotation depends on fontFamily Verdana

    FangAvatar

      I am rotating a textarea with text.Its rotate fine by the below code :

       

      public function rotateImage(zmrVal:int) : void
      {
      var selectedCanImg:Object=selectedThemeLayout.getChildByName(selectElementName);
      rotate.angleFrom=angle;
      selectedCanImg.setStyle("fontFamily","Verdana");
      selectedCanImg.setStyle("fontSize",12);
      rotate.originX=0//curWidth/2;
      rotate.originY=0//curHeight/2;
      angle = zmrVal;
      rotate.angleTo=zmrVal;
      rotate.target=selectedCanImg;
      rotate.play();

      }

       

      But the rotation is fixed for the fontFamily Verdana.If after rotation suppose 35 degree,then change the fontFamily Arial,the textarea rotate but the text is vanished,also if change bold or italic the text is not visible.

      Please suggest me if have any idea.Thanks in advance.

        • 1. Re: Rotation depends on fontFamily Verdana
          Richard_Abbott Level 3

          FangAvatar,

          to be able to rotate fonts you have to embed them, see eg

          http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_04.html

          for details of how to do this. Every font and font style you use must be embedded, so for example bold counts as different as ultimately it is based on a different font file.

          Richard

          • 2. Re: Rotation depends on fontFamily Verdana
            FangAvatar Level 1

            Thanks Richard,But I'm not getting from your refference website.I'm not able to generate the ttf file also.Please provide me code that you have done.

            • 3. Re: Rotation depends on fontFamily Verdana
              Richard_Abbott Level 3

              FangAvatar,

              depends if you are wanting to do it in mxml or actionscript. MXML format is

              @font-face {
                  src: url("../assets/MyriadWebPro.ttf");
                  fontFamily: myFontFamily;
                  advancedAntiAliasing: true;
              }
              or
              @font-face {
                  src: local("Myriad Web Pro");
                  fontFamily: myFontFamily;
                  advancedAntiAliasing: true;
              }
              and AS format is
                   [Embed(source='../assets/MyriadWebPro.ttf',
                      fontName='myMyriadFont',
                      mimeType='application/x-font'
                   )]
              or
                   [Embed(source='../assets/MyriadWebPro-Bold.ttf',
                      fontWeight='bold',
                      fontName='myBoldMyriadFont',
                      mimeType='application/x-font',
                      advancedAntiAliasing='true'
                   )]
              with the two variations depending if you want to use system name or location to describe the font.
              You then use the fontFamily or fontName to reference the embedded font in your code.
              I do recommend you have a look at the Adobe live docs examples which are far too long to copy and paste here!
              Richard


              • 4. Re: Rotation depends on fontFamily Verdana
                FangAvatar Level 1
                Richard I carefully study the Adobe live docs but when I want to built this example i got the src error,
                i don't know how to create the ttf file.Please help me.How i create the ttf file and also how i mention
                the font details?
                • 5. Re: Rotation depends on fontFamily Verdana
                  Richard_Abbott Level 3

                  FangAvatar,

                  a ttf file is a true-type font file and under normal circumstances you don't ever need to create one yourself. If you ever do, it's a completely separate task from using it in a Flex app! You should find that you already have ttf files in your fonts directory.

                  Also, the two different styles of referencing the font mean that you can use the system name rather than ever having to know the file location of the ttf. Some people prefer one and some the other, but both are legal. In your case you already know the system name (Verdana) so maybe use this route rather than tracking down where the file is situated.

                  Richard

                  • 6. Re: Rotation depends on fontFamily Verdana
                    FangAvatar Level 1

                    Richard, as you provide me I embed into my as file but i got the error.I have to implement my textarea for multiple style so as i know i have to use the

                    [Embed(source="assets/.ttf")].When i put the code i got the error.Could you tell me hor to proceed?
                    My code is below :

                                                       public function createTextinput():void
                                             {
                                                  numChild=selectedThemeLayout.numChildren;
                                                  if(numChild<=0)
                                                       numChild=1;

                                                  var textinputObject:TextArea = selectedThemeLayout.addChild(new TextArea()) as TextArea;
                                                        
                                                textinputObject.x=ImgX - xOff;
                                                textinputObject.y=ImgY - yOff;
                                                  textinputObject.height=30;
                                                  if(layType==1)
                                                       textinputObject.width=250;
                                                       
                                                  if(layType==2)
                                                       textinputObject.width=350;
                                                       
                                                  textinputObject.setStyle("fontSize",13);
                                                  //textinputObject.setStyle("borderStyle","solid");
                                                  textinputObject.setStyle("borderThickness",0);
                                                  textinputObject.setStyle("backgroundAlpha",0);
                                                  textinputObject.setStyle("borderColor",0);
                                                  textinputObject.setStyle("backgroundColor","transparent");
                                                  textinputObject.verticalScrollPolicy="off";
                                                  
                                                   if(withText){
                                                        textinputObject.text=textBoxText;
                                                        textinputObject.height=textBoxH;
                                                        textinputObject.width=textBoxW;
                                                        textinputObject.setStyle("fontFamily",textBoxFont);
                                                        textinputObject.setStyle("fontWeight",textBoxB);
                                                        textinputObject.setStyle("fontStyle",textBoxI);
                                                        textinputObject.setStyle("textDecoration",textBoxU);
                                                        textinputObject.setStyle("fontSize",int(textBoxSize));
                                                        textinputObject.setStyle("color",textBoxColor);
                                                        textinputObject.explicitHeight =textBoxHeight+10;
                                                   }
                                                        
                                                    selectControl(textinputObject,true,'TEXT');

                                                  }

                    I am create the text area here and set the default style here.After this I am call a rotate image function.
                    Pleaes help me.
                    • 7. Re: Rotation depends on fontFamily Verdana
                      FangAvatar Level 1

                      How can i write the embed in simple as file.This is not package and not define in mxml file.

                      • 8. Re: Rotation depends on fontFamily Verdana
                        Richard_Abbott Level 3

                        FangAvatar,

                        a bit short of time just now but you have the line

                        [Embed(source="assets/.ttf")]
                        This will surely fail. You must use a valid ttf file location and this is not one. Either put a proper file name in there,
                        or use a system font name not location.
                        Richard
                        • 9. Re: Rotation depends on fontFamily Verdana
                          FangAvatar Level 1

                          No no for example i am showing that way , ofcaurse there was a valid ttf name.I think its my fault i am not able to built this.is there any as class where we define the ttf name?

                           

                          Also

                          <mx:Script>
                               /*
                                * Embed a font by name.
                                */
                               [Embed(systemFont='Arial',
                                  fontName='myPlainFont',
                                  mimeType='application/x-font'
                               )]
                               // You do not use this variable directly. It exists so that
                               // the compiler will link in the font.
                               private var font1:Class;
                              
                               /*
                                * Embed a font with italic typeface by name.
                                */
                               [Embed(systemFont='Verdana',
                                  fontStyle='italic',
                                  fontName='myItalicFont',
                                  mimeType='application/x-font',
                                  advancedAntiAliasing='true'
                               )]
                               private var font2:Class;
                              
                            </mx:Script>

                          Here they wrote 2 different embed style.in our project a text area have a lots of style.Could I mention (default)
                          all the style(fontfamily,fontsize,fontweight,fontstyle)?
                          • 10. Re: Rotation depends on fontFamily Verdana
                            FangAvatar Level 1
                            Richard I am provide you the code.could you please embed the style for that textarea particularly?So i can understand properly.
                            • 11. Re: Rotation depends on fontFamily Verdana
                              Richard_Abbott Level 3

                              FangAvatar,

                              most fonts have four different files - normal, bold, italic and bold-italic.

                              So for each style that you use you must embed the specific file.

                              As for the steps in applying the font to the style to the object, check the Adobe documentation...

                              Richard

                              • 12. Re: Rotation depends on fontFamily Verdana
                                FangAvatar Level 1
                                Richard

                                Thanks
                                Richard,so you mean i have to generate the combination suppose fontfamily Arial and fontweight bold,another is Verdana and Italic etc.
                                The possible combinations i have manually generate.right?
                                • 13. Re: Rotation depends on fontFamily Verdana
                                  FangAvatar Level 1
                                  Richard in the below example in style script they specify the style.And then embed,not use the variable
                                  directly.But in the Vbox use the style name , not mention the embed.Why?
                                  <mx:Style>
                                       .mystyle1 {
                                          fontFamily:myMyriadFont;
                                          fontSize: 32pt;
                                       }
                                       .mystyle2 {
                                          fontFamily:myBoldMyriadFont;
                                          fontSize: 32pt;
                                          fontWeight: bold;
                                       }
                                    </mx:Style>
                                   
                                    <mx:Script>
                                       /*
                                        * Embed a font by location.
                                        */
                                       [Embed(source='../assets/MyriadWebPro.ttf',
                                          fontName='myMyriadFont',
                                          mimeType='application/x-font'
                                       )]
                                       // You do not use this variable directly. It exists so that
                                       // the compiler will link in the font.
                                       private var font1:Class;
                                      
                                       /*
                                        * Embed a font with bold typeface by location.
                                        */
                                       [Embed(source='../assets/MyriadWebPro-Bold.ttf',
                                          fontWeight='bold',
                                          fontName='myBoldMyriadFont',
                                          mimeType='application/x-font',
                                          advancedAntiAliasing='true'
                                       )]
                                       private var font2:Class;
                                      
                                    </mx:Script>

                                    <mx:Panel title="Embedded Fonts Using ActionScript">
                                       <mx:VBox>
                                          <mx:Label
                                              width="100%"
                                              height="75"
                                              styleName="mystyle1"
                                              text="This text uses the MyriadWebPro font."
                                              rotation="15"
                                          />
                                          <mx:Label
                                              width="100%"
                                              height="75"
                                              styleName="mystyle2"
                                              text="This text uses the MyriadWebPro-Bold font."
                                              rotation="15"
                                          />
                                       </mx:VBox>
                                    </mx:Panel>
                                  • 14. Re: Rotation depends on fontFamily Verdana
                                    Richard_Abbott Level 3

                                    FangAvatar,

                                    in one post you wrote

                                    "The possible combinations i have manually generate.right?"

                                    Yes, but only the actual combinations you need. You can ignore those you don't care about.

                                    And also

                                    "in style script they specify the style.And then embed,not use the variable
                                    directly.But in the Vbox use the style name , not mention the embed.Why?"

                                    Because the font is embedded just once into the SWF file, but can then be referenced

                                    multiple times by different component classes or indeed individual components.

                                    This way gives you much more flexibility and efficiency in terms of the end result.

                                    Richard

                                    • 15. Re: Rotation depends on fontFamily Verdana
                                      FangAvatar Level 1

                                      But Richard we have lot of fontfamily whatever we can choose from the list.Suppose we mention only verdana and not possible to mention all.So what will do?

                                      • 16. Re: Rotation depends on fontFamily Verdana
                                        FangAvatar Level 1

                                        Richard lots of thanks to you.Is this your working time Richard?I have to leave now.If I am not able to built then please come tomorrow.Thanks again Richard.

                                        • 17. Re: Rotation depends on fontFamily Verdana
                                          Richard_Abbott Level 3

                                          FangAvatar,

                                          you wrote

                                          "Suppose we mention only verdana and not possible to mention all.So what will do?"

                                          Well, it is a problem! You have to pick a certain number at design/build time.

                                          Otherwise you are just relying on whatever your user has installed and with different O/S etc you cannot know this.

                                          This is not just a Flex problem, it applies equally to any distributed content.

                                          For example in Word you can choose whether to save the embedded font with the document or else just hope the end-user has it already.

                                          And also "Richard lots of thanks to you" - no problem!

                                          Richard

                                          • 18. Re: Rotation depends on fontFamily Verdana
                                            FangAvatar Level 1

                                            a ttf file is a true-type font file and under normal circumstances you don't ever need to create one yourself. If you ever do, it's a completely separate task from using it in a Flex app! You should find that you already have ttf files in your fonts directory.

                                            Also, the two different styles of referencing the font mean that you can use the system name rather than ever having to know the file location of the ttf. Some people prefer one and some the other, but both are legal. In your case you already know the system name (Verdana) so maybe use this route rather than tracking down where the file is situated.

                                             

                                            Richard as you post this content,How could I know in my fonts directory have ttf file?would yo talk ablot  /src/assets/fonts/ directory?Please explain me.

                                             

                                            • 19. Re: Rotation depends on fontFamily Verdana
                                              Richard_Abbott Level 3

                                              Morning FangAvatar!

                                              once the application is compiled into a SWF file then everything is included inside it.

                                              However, in order to compile it Flex needs to be able to locate all the resources it needs to do so, including fonts.

                                              Now, lots of folk have a convention that everything that is a resource, such as images, fonts etc goes into an assets folder within their project so they can find it in the structure. The Adobe help files do this, and you'll see lots of sample code also. Personally I must admit I don't do that, and it is not required by Flex, just a matter of practice.

                                              Now, when including a font file you can either reference it by its file location or by its system name.

                                              If you are on Windows then the file location is probably C:\WINDOWS\Fonts... but it may not be depending what font you are using and where you got it from! Hence if you are going to use a file location, it makes sense to make a copy of the ttf font file into your project structure, eg  /src/assets/fonts/. You can use the original location, but it might make it harder to share the project with someone else if you ever needed to.

                                              If you use the system font name then this doesn't matter because it is the OS problem to find the font.

                                              Richard

                                              • 20. Re: Rotation depends on fontFamily Verdana
                                                FangAvatar Level 1

                                                Morning too Richard.I understand your point.But in 2 days I found from google several website and know that if I'm using system font in rotation time may not be worked.What about your comments?

                                                Also I'm got several ttf file,i'm attached here arial.ttf file.Could i manually put this file into /src/assets/fonts/ directory?Are you here within 4-5 hrs or leave you?

                                                • 21. Re: Rotation depends on fontFamily Verdana
                                                  FangAvatar Level 1

                                                  Richard did you have any idea about scrapblog.com rotation?The text area rotation which I am built have some problem,if you have any idea please tell me.

                                                  • 22. Re: Rotation depends on fontFamily Verdana
                                                    Richard_Abbott Level 3

                                                    Hi FangAvatar,


                                                    you wrote

                                                    "Also I'm got several ttf file,i'm attached here arial.ttf file.Could i manually put this file into /src/assets/fonts/ directory?"

                                                    Yes, you should just be able to make a straight copy into that folder without problems. About the only difficulties there ever are with font files are legal ones if you are using a font that has licence or distribution restrictions. But Arial certainly doesn't.

                                                    Sorry, I have not come across scrapblog before. From what you say I'm guessing that the blog text rotates in response to some user action?

                                                    Richard

                                                    • 23. Re: Rotation depends on fontFamily Verdana
                                                      FangAvatar Level 1

                                                      http://www.scrapblog.com/ goto top right corner "Create a scrapblg".Anything you rotate via onmouse effect.

                                                      • 24. Re: Rotation depends on fontFamily Verdana
                                                        Richard_Abbott Level 3

                                                        Nice, haven't seen that one before, thanks for the link!

                                                        There's a lot of work in it, but hopefully you should be getting the text rotation sorted before long...

                                                        Richard

                                                        • 25. Re: Rotation depends on fontFamily Verdana
                                                          FangAvatar Level 1

                                                          Richard the embedded fonts is not working.In my mxml file I put the thing :

                                                           

                                                          <mx:Style>
                                                              .myPlainStyle {
                                                                  fontFamily: myMyriadFont;
                                                                  fontSize: 24;
                                                               }
                                                               .myItalicStyle {
                                                                  fontFamily: myItalicMyriadFont;
                                                                  fontSize: 24;
                                                                  fontStyle: italic;
                                                               }
                                                               .myBoldStyle {
                                                                  fontFamily: myBoldMyriadFont;
                                                                  fontSize: 24;
                                                                  fontWeight: bold;
                                                               }
                                                            </mx:Style>
                                                           
                                                            <mx:Script>
                                                               /*
                                                                * Embed a font by location.
                                                                */
                                                               [Embed(source='file:///c:/windows/fonts/ARIAL.ttf',
                                                                  fontName='myMyriadFont',
                                                                  mimeType='application/x-font'
                                                               )]
                                                               // You do not use this variable directly. It exists so that
                                                               // the compiler will link in the font.
                                                               private var font1:Class;
                                                              
                                                               /*
                                                                * Embed a font with bold typeface by location.
                                                                */
                                                               [Embed(source='file:///c:/windows/fonts/ARIALBD.ttf',
                                                                  fontWeight='bold',
                                                                  fontName='myBoldMyriadFont',
                                                                  mimeType='application/x-font',
                                                                  advancedAntiAliasing='true'
                                                               )]
                                                               private var font2:Class;
                                                              
                                                               [Embed(source='file:///c:/windows/fonts/ARIALI.ttf',
                                                                  fontWeight='italic',
                                                                  fontName='myItalicMyriadFont',
                                                                  mimeType='application/x-font',
                                                                  advancedAntiAliasing='true'
                                                               )]
                                                               private var font3:Class;
                                                              
                                                            </mx:Script>

                                                          and in as file where i have generate the text area put the style name.But not worked.I have generate textarea in the below way :

                                                           

                                                          var textinputObject:TextArea = selectedThemeLayout.addChild(new TextArea()) as TextArea;                         

                                                           

                                                          Now I am trying to add style

                                                          textinputObject.styleName=myItalicStyle not getting (error occured)
                                                          Also there was no option for
                                                          textinputObject .embedFonts=true

                                                          Please advise me.

                                                          • 26. Re: Rotation depends on fontFamily Verdana
                                                            Richard_Abbott Level 3

                                                            FangAvatar,

                                                            you have said

                                                            textinputObject.styleName=myItalicStyle;

                                                            but myItalicStyle is a string identifier for the style so you need

                                                            textinputObject.styleName="myItalicStyle";

                                                            At a guess, the error you were getting was to do with a type mismatch, or that the compiler couldn't understand what it thought was a variable name.

                                                            Re textinputObject .embedFonts=true, then if you look at the TextArea documentation in http://www.adobe.com/livedocs/flex/3/langref/ then you will see that indeed there is no embedFonts property. But I don't think you need on in the text area - it is the application as a whole that has the fonts embedded, and a given component only needs to be indicated via the styleName property to make use of it.

                                                            Richard

                                                            • 27. Re: Rotation depends on fontFamily Verdana
                                                              FangAvatar Level 1

                                                              Thanks Richard it's working fine.I am not set embedFonts=true , but working.

                                                               

                                                              Now my another issue is same as scrapblog i've lots of fonts option.I set default Arial,24 and bold.When i change italic to normal call a function and selectedTextField.setStyle("fontStyle","normal").Is there any need to embed?I called several function like bold,italic,underline,fontsize,fontfamily etc.When I change the font what will I do?How can I embed on the function.

                                                               

                                                              Next after rotation if i change the fonefamily or bold or italic then the text again vanished.I think I havo to embed after call the desired functions.

                                                               

                                                              Please advise me Richard I'm waiting here.

                                                              • 28. Re: Rotation depends on fontFamily Verdana
                                                                Richard_Abbott Level 3

                                                                FangAvatar,

                                                                glad to hear things are going well. About embedding, then remember that there are 4 files for any given font (regular, bold, italic, and bold-italic). You must embed each one that youa re using - for example if you have done bold and italic, it will not work out how to do bold-italic on its own. I don't think the font size makes any difference as the ttf file effectively contains multiple sizes inside it.

                                                                Same with a change of actual font. Every single one that you want as an option must be embedded (sorry but that's just how it works!). So maybe it would be good not to have too many options...

                                                                Richard

                                                                • 29. Re: Rotation depends on fontFamily Verdana
                                                                  FangAvatar Level 1

                                                                  Richard my problem is by default as i post my code in mxml file put the arial ttf file from the windows font.Now I rotate the textarea and bold or italic or underline all are works fine.But when i change the fontfamily from my combo box the content vanish.What will i do?Please help me.

                                                                  • 30. Re: Rotation depends on fontFamily Verdana
                                                                    Richard_Abbott Level 3

                                                                    FangAvatar,

                                                                    how many fonts do you have in your combo box? Each one must have the same treatment as Arial, ie copy the ttf file somewhere suitable and do the embedding of each one. Any time you are rotating text the font you are using at the time must be embedded. That's why I said last time that you might want to limit the number of choices. Each font you embed is also increasing the size of your SWF file, so you must trade off freedom of choice against becoming too cumbersome. This can only be done by testing it out across a remote link (so not just off local machine), plus of course how many embed statements and style names you can be bothered to do. You have solved the real problem of doing it in principle, it is only a matter of how many times you want to turn the handle. If I were you I'd be happy with a couple of fonts at first and make sure I could solve other parts of the problem. You can always go back and add more later as an upgrade!

                                                                    Richard

                                                                    • 31. Re: Rotation depends on fontFamily Verdana
                                                                      FangAvatar Level 1

                                                                      Richard I am using suppose 50 fonts.So for every font in my mxml file include the below code as I mention for Arial.

                                                                      <mx:Style>
                                                                          .myPlainStyle {
                                                                              fontFamily: myFont;
                                                                              fontSize: 24;
                                                                           }
                                                                           .myItalicStyle {
                                                                              fontFamily: myFont;
                                                                              fontSize: 24;
                                                                              fontStyle: italic;
                                                                           }
                                                                           .myBoldStyle {
                                                                              fontFamily: myFont;
                                                                              fontSize: 24;
                                                                              fontWeight: bold;
                                                                           }
                                                                           .myItalicBoldStyle {
                                                                              fontFamily: myFont;
                                                                              fontSize: 24;
                                                                              fontStyle: italic;
                                                                              fontWeight: bold;
                                                                           }
                                                                         
                                                                        </mx:Style>
                                                                       
                                                                        <mx:Script>
                                                                           /*
                                                                            * Embed a font by location.
                                                                            */
                                                                           [Embed(source='file:///c:/windows/fonts/ARIAL.ttf',
                                                                              fontName='myFont',
                                                                              mimeType='application/x-font'
                                                                           )]
                                                                           private var font1:Class;
                                                                          
                                                                           // You do not use this variable directly. It exists so that
                                                                           // the compiler will link in the font.
                                                                          
                                                                          
                                                                           /*
                                                                            * Embed a font with bold typeface by location.
                                                                            */
                                                                           [Embed(source='file:///c:/windows/fonts/ARIALBD.ttf',
                                                                              fontWeight='bold',
                                                                              fontName='myFont',
                                                                              mimeType='application/x-font',
                                                                              advancedAntiAliasing='true'
                                                                           )]
                                                                           private var font2:Class;
                                                                          
                                                                           [Embed(source='file:///c:/windows/fonts/ARIALI.ttf',
                                                                              fontStyle='italic',
                                                                              fontName='myFont',
                                                                              mimeType='application/x-font',
                                                                              advancedAntiAliasing='true'
                                                                           )]
                                                                           private var font3:Class;
                                                                          
                                                                            [Embed(source='file:///c:/windows/fonts/ARIALBI.ttf',
                                                                              fontStyle='italic',
                                                                              fontWeight='bold', 
                                                                              fontName='myFont',
                                                                              mimeType='application/x-font',
                                                                              advancedAntiAliasing='true'
                                                                           )]
                                                                           private var font4:Class;
                                                                          
                                                                        </mx:Script>

                                                                      Suppose for verdana I have to embed bold,italic,bold-italic and plain.Right?But when i change the fontfamily vai a function did i mention anything?When rotate did I mention anything about style?In my as file I am just mention the stylename only once when i create the text area.

                                                                      • 32. Re: Rotation depends on fontFamily Verdana
                                                                        FangAvatar Level 1

                                                                        Richard in my code for plain the style name is myPlainStyle.and suppose in text area creation i add this stylename.But if I add new style suupose verdana.Fow Verdana plain what will i write?

                                                                        • 33. Re: Rotation depends on fontFamily Verdana
                                                                          Richard_Abbott Level 3

                                                                          FangAvatar,

                                                                          wow... 50 fonts... you are much more patient than I would be!

                                                                          Yes, each one has to have different style names as well, so you need to have some sort of convention for naming such as

                                                                          myArialPlainStyle, myArialBoldStyle...

                                                                          myVerdanaPlainStyle, myVerdanaBoldStyle...

                                                                          ...

                                                                          There are, I suspect, clever things you can do with the Flex style object as styles can in fact be created in ActionScript at runtime, so you may well be able to do this part on the fly as a user picks a new font. That would certainly save code. Have a look at the StyleManager class in the Adobe live docs (http://www.adobe.com/livedocs/flex/3/langref/) and also the online help section called "Creating style declarations with the StyleManager" on the page

                                                                          http://www.adobe.com/livedocs/flex/3/html/help.html?content=styles_07.html

                                                                          Personally I'd get a feel how it works for a small number first before tackling the larger number...

                                                                          But every single separate font has to be embedded at compile time since only at this stage can you guarantee that yuo have the list you want.

                                                                          Richard

                                                                          • 34. Re: Rotation depends on fontFamily Verdana
                                                                            FangAvatar Level 1

                                                                            Richard thanks for this answer.But as you tell me for arial style name one and for verdana styname is another.But in textarea creation time i have mention suppose plainarial stylename.But when i change the fontfamily from combobox then how it will change?I have mention every fontFamily name is myFont.

                                                                            • 35. Re: Rotation depends on fontFamily Verdana
                                                                              Richard_Abbott Level 3

                                                                              FangAvatar,

                                                                              when you change the font family name in the combo, you must make sure that the style name is also changed for the text area. basically you must give enough information at runtime when you select the new font from your combo as you have set up initially for Arial. I would try doing it just for one other font first to get the feel of what's needed, then build up from there, rather than trying to solve all 50 in one go.

                                                                              Richard

                                                                              • 36. Re: Rotation depends on fontFamily Verdana
                                                                                FangAvatar Level 1

                                                                                Richard as you say to me I have to know the stylename when i want to chnage fontfamily.But how can i chnage style when i choose fontfamily from the combo.Suppose i have style name .plainArial for Arial.And verdane is .plainVerdana.i know this for 2 fonts.Now when i change this not possible to wrote the style hardcoded.May be i have to update the plainArial or write other.I have used the stylemanager,but not worked.Please advice me first for 2 style.

                                                                                Thanks

                                                                                • 37. Re: Rotation depends on fontFamily Verdana
                                                                                  Richard_Abbott Level 3

                                                                                  FangAvatar,


                                                                                  it's a holiday period over here in the UK so I shall be erratic onlist for the next few days! But I did catch this message of yours. Basically you need some kind of data structure that keeps track of the different implications of the user choice in the combo. So when they choose say index 5 in your list, that means that the combo must display the right text (obvious, but needs remembering!), the selection of font must change, style names etc. The best way to do that (in my view) would be to have a data structure that you set up when the application initialises. Personally I'd use an XML file which contains the font display names for your combo as well as style names and anything else you want. I don't know how your are storing the font names just now but if they are just hard-coded into your combo that is the least flexible way. Keep them in a separate data structure like XML and then you can use the same structure as the data provider for your combo and many other tasks beside. In the future you can even move the structure outside your app and then be able to change some features without the need to recompile the SWF, but that's for a later development stage.

                                                                                  Once you have the data structure tied to your combo, then the change event triggered by the user action can make use of the selection into the structure to pick out every other detail you need like style names - much easier than trying to keep track of several different arrays and hoping that they all stay in synch with each other.

                                                                                  I always find that working in small steps towards the goal is good, otherwise you can't easily see which of your code is failing. So before going down the route of data structures and the like, have you been able to use just two fonts and change between them at runtime? Once this step is successful then you can start to generalise. In terms of a strategy for two fonts you have something like:

                                                                                  While compiling:

                                                                                  Embed both fonts together with style names etc

                                                                                  Have one of the fonts defined as your default one

                                                                                  Start of app:

                                                                                  Set things up for the default font (ie point the text area style at the right place)

                                                                                  Combo change event:

                                                                                  Make sure you can swap successfully to the second font

                                                                                  Then alter your defaut font to the other one and make sure that all works too.

                                                                                   

                                                                                  Then you can start to work on generalising to more fonts, but you are now sure that the basic steps are in place corrrectly.

                                                                                  Hope it works out and have a good break if it's a holiday for you as well!

                                                                                  Richard

                                                                                  • 38. Re: Rotation depends on fontFamily Verdana
                                                                                    FangAvatar Level 1

                                                                                    Thanks Richard,today is holiday so keep enjoying.And i'll try as you say to me.If my problem is done then great but if not then i'll back to you very soon.

                                                                                    Thanks

                                                                                    • 39. Re: Rotation depends on fontFamily Verdana
                                                                                      Flex harUI Adobe Employee

                                                                                      In theory, if your combobox selectedItem can be "Arial" or "Verdana", then you can call

                                                                                       

                                                                                      setStyle("styleName", ".my" + combobox.selectedItem + "Style");

                                                                                       

                                                                                      Alex Harui

                                                                                      Flex SDK Developer

                                                                                      Adobe Systems Inc.

                                                                                      Blog: http://blogs.adobe.com/aharui

                                                                                      1 2 Previous Next