2 Replies Latest reply on Oct 4, 2010 1:42 PM by eastportme

    SkinnableContainer kills linebreaking?

    eastportme

      I've only been using Flex/Flashbuilder for about two weeks, so apologies if this is just newbie confusion...

       

      After struggling to set backgrounds in HGroups and VGroups I finally learned about skinning. I converted one of my other containers to a SkinnableContainer, created the simplest possible (I think) Skin, and now my RichText component no longer linebreaks! This is despite setting the lineBreak attribute to "toFit" in every conceivable place.

       

      The layout I'm working with is fairly complex, but I've reduce the problem to the code below. You'll see the SkinnableContainer -- there is also a commented out Group tag near it. If I remove the SkinnableContainer and replace it with a simple Group, line breaking occurs as I expect. Below this code is the Skin I am using. Any guidance would be most welcome; I had been planning to use a large set of SkinnableContainter components containing blocks of text for my app, but if linebreaking won't work, I've got a problem. Below the code I include images of the screen, once with the SkinnableContainer, and once with the plain Group.

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                        xmlns:s="library://ns.adobe.com/flex/spark" 
                        xmlns:mx="library://ns.adobe.com/flex/mx" 
                        minWidth="955" minHeight="600" xmlns:components="components.*">
           
           <fx:Declarations>
           </fx:Declarations>
           <fx:Style source="assets/ad.css"/>
           <s:Group width="100%" height="100%">
                <s:SkinnableContainer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                                           xmlns:s="library://ns.adobe.com/flex/spark" 
                                           xmlns:mx="library://ns.adobe.com/flex/mx"  skinClass="advanced_directive_skins.WhiteSkin"  
                                           width="100%" >
                     <!--<s:Group width="100%">-->
                     <fx:Script>
                          <![CDATA[
                               import ad_skins.WhiteSkin;
                               
                          ]]>
                     </fx:Script>
                     
                     <s:Group width="100%" height="100%" x="0" y="0">
                          <s:RichText paddingTop="15" paddingLeft="15" paddingRight="30" lineBreak="toFit" width="100%">                                                                                                              
                               <s:textFlow>
                                    <s:TextFlow lineBreak="toFit">                                        
                                         <s:div fontSize="22" fontWeight="bold" color="#715304">Gettysburg Address
                                         </s:div>
                                         <s:div fontSize="14">
                                              <s:p paragraphSpaceBefore="10" paragraphStartIndent="0" lineBreak="toFit">Four score and seven years ago our 
                                                   fathers brought forth on this continent, a new nation, conceived in Liberty, 
                                                   and dedicated to the proposition that all men are created equal.                                                   
                                                   Now we are engaged in a great civil war, testing whether that nation, 
                                                   or any nation so conceived and so dedicated, can long endure. We are met 
                                                   on a great battle-field of that war. We have come to dedicate a portion of that field, 
                                                   as a final resting place for those who here gave their lives that that nation might 
                                                   live. It is altogether fitting and proper that we should do this.                                                  
                                                   But, in a larger sense, we can not dedicate - we can not consecrate 
                                                   - we can not hallow - this ground. The brave men, living and dead, 
                                                   who struggled here, have consecrated it, far above our poor power to add or detract. 
                                                   The world will little note, nor long remember what we say here, but it can never 
                                                   forget what they did here. It is for us the living, rather, to be dedicated here 
                                                   to the unfinished work which they who fought here have thus far so nobly advanced. 
                                                   It is rather for us to be here dedicated to the great task remaining before us - 
                                                   that from these honored dead we take increased devotion to that cause for which they 
                                                   gave the last full measure of devotion - that we here highly resolve that these dead 
                                                   shall not have died in vain - that this nation, under God, shall have a new birth of 
                                                   freedom - and that government of the people, by the people, for the people, shall not 
                                                   perish from the earth.
                                              </s:p>
                                         </s:div>
                                    </s:TextFlow>
                               </s:textFlow>
                          </s:RichText>
                     </s:Group>
                </s:SkinnableContainer>
                <!--</s:Group>-->
           </s:Group>
      </s:Application>
      

       

       

      And the skin:

       

       

      <?xml version="1.0" encoding="utf-8"?>
      <s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
                xmlns:s="library://ns.adobe.com/flex/spark" 
                xmlns:mx="library://ns.adobe.com/flex/mx">
           <fx:Metadata>
                [HostComponent("spark.components.SkinnableContainer")]
           </fx:Metadata>
           <fx:Declarations>
                <!-- Place non-visual elements (e.g., services, value objects) here -->
           </fx:Declarations>
           <s:states>
                <s:State name="normal"/>
                <s:State name="disabled"/>
           </s:states>
           
           <s:Rect x="0" y="0" height="100%" width="100%">
                <s:fill>
                     <s:SolidColor color="#FFFFFF"/>               
                </s:fill>
           </s:Rect>
           
           <s:Group id="contentGroup">
                <s:layout><s:BasicLayout/></s:layout>
           </s:Group>
      </s:Skin>
      
      The appearance with SkinnableContainer:
      skinnablecontainer.PNG

      ...and the appearance with Group:

      group.PNG

       

      Thanks for any help!