2011-03-14 26 views
1

我可能會服用瘋狂的藥丸,但有人實際上得到了errorSkin功能工作?我沒有做任何瘋狂的事情,只是擴展TextInput(spark)並設置errorSkin屬性。SparkSkinInput驗證錯誤的皮膚

我曾嘗試使用SparkSkin創建皮膚,什麼也沒做。 我已經嘗試使用ProgrammaticSkin創建皮膚,什麼也沒做。

TextInput始終是紅色邊框。我知道你可以設置errorColor和errorString,但我顯然希望做的不僅僅是改變邊框的顏色。我正在使用Flex 4.1進行編譯。

任何想法?

執行力度:

<components:PromptedTextInput id="txt" 
     width="200" 
     horizontalCenter="0" 
     verticalCenter="0" 
     errorSkin="skins.TestSkin" /> 

public class PromptedTextInput extends TextInput 
{ 

    public function PromptedTextInput() 
    { 
     super(); 
    } 

} 

錯誤皮膚:

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"> 
<fx:Metadata> 
    <![CDATA[ 

    [HostComponent("spark.components.TextInput")] 

    ]]> 
</fx:Metadata> 

<s:states> 
    <s:State name="normal" /> 
    <s:State name="disabled" /> 
    <s:State name="error" /> 
</s:states> 

<!-- fill --> 
<s:Rect id="background" 
     left="1" right="1" top="1" bottom="1"> 
    <s:fill> 
     <!--- Defines the background fill color. --> 
     <s:SolidColor id="bgFill" 
       color="#66CC66" /> 
    </s:fill> 
</s:Rect> 
</s:SparkSkin> 

另一個錯誤皮膚嘗試:

public class TestSkin extends ProgrammaticSkin 
{ 
    public function TestSkin() 
    { 
     super(); 
    } 

    override protected function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void 
    { 
     super.updateDisplayList(unscaledWidth, unscaledHeight); 
     graphics.clear(); 
     graphics.beginFill(0x33CC33); 
     graphics.drawRect(0, 0, unscaledWidth, unscaledHeight); 
     graphics.endFill(); 
    } 
} 
+0

如果errorSkin是替換皮膚;你不需要更多的僅僅是一個彩色背景嗎?嘗試重新創建您的ErrorSkin作爲TextInput外觀的副本。 – JeffryHouser 2011-03-14 23:07:20

回答

1

嗯,它不漂亮,但它看起來像有兩個皮膚必須改變。 ErrorSkin和FocusSkin。好消息是,你可以讓他們一樣。對於皮膚,爲了測試,我完全複製了Adobe的ErrorSkin類。可悲的是,即使將顏色硬編碼到皮膚中,我仍然可以看到一個紅色的像素點在邊界的角落。如果我解決了問題,我會盡力更新。謝謝大家。

<s:TextInput id="txt" 
      width="200" 
      focusSkin="skins.NewErrorSkin" 
      horizontalCenter="0" 
      verticalCenter="0" 
      errorSkin="skins.NewErrorSkin" /> 

UPDATE

音啞,它prolly不過是剛剛設置的errorColor樣式的ErrorSkin的processBitmap()函數。在這裏,我將錯誤邊界硬編碼爲0x99CC66

override protected function processBitmap():void 
{ 
    // Apply the glow filter 
    rect.x = rect.y = 0; 
    rect.width = bitmap.bitmapData.width; 
    rect.height = bitmap.bitmapData.height; 

    target.setStyle("errorColor", 0x99cc66); 
    glowFilter.color = 0x99cc66; 

    bitmap.bitmapData.applyFilter(bitmap.bitmapData, rect, filterPt, glowFilter); 
} 
1

您是否試圖創建基於\ Flex 4.1 \ frameworks \ projects \ spark \ src \ spark \ skins \ spark \ ErrorSkin.as中的ErrorSkin(不是TextInput皮膚)的皮膚?

+0

Uhhhgggg,我的錯傢伙。基本上,由於某種原因,未縮放的寬度和高度爲零。硬編碼的圖形的高度和寬度至少顯示。它仍然不能正常工作。圖形看起來似乎被控制了。紅色邊框仍在下方顯示。 – 2011-03-15 18:19:09