2013-02-21 76 views
0

我創建了從TextInputSkin如何給TextInput外觀到TextInput控件在Flex 4.5中移動

延伸
package skins 
{ 

    import assets.TextInput_389X35; 

    import spark.skins.mobile.TextInputSkin; 

    public class RoundedTextInputSkin extends TextInputSkin 
    { 

     public function RoundedTextInputSkin() 
     { 
      super(); 
      borderClass = TextInput_389X35; 
      layoutBorderSize = 5; 
     } 
    } 
} 

類RoundedTextInputSkin現在,我已經給這個皮膚的skinClass到TextInput控件。我能夠看到roundedTextInput,但在textinput中輸入的文本不可見。 任何人都可以告訴我我的代碼出了什麼問題。

這裏是我的FXG文件

<?xml version="1.0" encoding="utf-8" ?> 
<Graphic version="2.0" ai:appVersion="16.0.0.682" ATE:version="1.0.0" flm:version="1.0.0" d:using="" xmlns="http://ns.adobe.com/fxg/2008" xmlns:ATE="http://ns.adobe.com/ate/2009" xmlns:ai="http://ns.adobe.com/ai/2009" xmlns:d="http://ns.adobe.com/fxg/2008/dt" xmlns:flm="http://ns.adobe.com/flame/2008"> 
     <Group x="3" y="1.35449" ai:seqID="1" flm:knockout="false"> 
     <Rect x="0.5" y="0.5" width="389" height="35" radiusX="16.9997" radiusY="16.9997" ai:seqID="2"> 
      <fill> 
      <LinearGradient x="194.5" y="0.38916" scaleX="34.2022" rotation="90"> 
       <GradientEntry ratio="0" color="#B0B0B0"/> 
       <GradientEntry ratio="1" color="#E0E0E0"/> 
      </LinearGradient> 
      </fill> 
     </Rect> 
     <Rect x="0.5" y="0.5" width="389" height="35" radiusX="16.9997" radiusY="16.9997" ai:seqID="3"/> 
     </Group> 
</Graphic> 

回答

0

並不清楚你的FXG文件如何與皮膚類,你表現。但是,我將假設您提供的FXG是代碼中引用的TextInput_389X35。我假設你的自定義邊框位於所有其他元素之上;使他們看不見。根據TextSkinBase的createChildren()方法;邊界元素置於一切之上:

override protected function createChildren():void 
{ 
super.createChildren(); 
if (!textDisplay) 
{ 
    textDisplay = StyleableTextField(createInFontContext(StyleableTextField)); 
    textDisplay.styleName = this; 
    textDisplay.editable = true; 
    textDisplay.useTightTextBounds = false; 
    addChild(textDisplay); 
} 

if (!border) 
{ 
    border = new borderClass(); 
    addChild(border); 
} 
} 

默認邊框FXG元素使用路徑來創建邊框,使「補」是一個邊界。通過使用矩形,您可以在其他任何地方放置一個大方形。

+0

感謝評論flextras。我試着把代碼添加到createChildren中,但仍然無法看到在textinput中輸入的文本。我已經給borderClass = TextInput_389X35; TextInpu_389X35是fxg。 – Trinu 2013-02-22 06:41:59

+0

@Trinu那不是我的代碼;它直接從TextSkinBase複製,以顯示BorderClass是最後添加的;從而掩蓋了一切。如果你想重寫createChildren()以便邊框類放在最下面;你可以做到這一點。但是,我認爲你會更適合重新使用FXG來使用路徑而不是矩形。 – JeffryHouser 2013-02-22 15:02:21

+0

@Flextras如何使用路徑而不是矩形我在Adobe Illustrator中嘗試過,它總是給我一個矩形而不是路徑。可以請你幫我一下。我無法看到textinput中的文字。 – Trinu 2013-02-25 09:17:26

相關問題