2012-03-20 56 views
1

我想知道是否有可能對皮膚鑑於我的Flex 移動應用:Flex手機:如何查看皮膚?

ActivityView.as

public class ActivityView extends View 

ActivityViewSkin.mxml(它皮膚相關)

<?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"> 

<fx:Metadata> 
    [HostComponent("com.corp.views.activity.ActivityView")] 
    ... 

這是移動開發的好方法嗎?

我該如何使用這這個皮膚

<s:navigationContent> 

非常感謝您!

安東尼

回答

0

沒有。 Spark皮膚未針對移動設備進行優化。你應該使用MobileSkin。 (僅限動作腳本)。

0

我一直在尋找類似的信息,然而我可以從文檔和博客中推論出的所有東西都暗示了MobileSkin是您爲組件級別蒙皮(例如按鈕,列表,itemRenderers等)所做的事情,將會使用的東西很多次在整個應用程序。

另外一個原因認爲你可能能夠通過MXML剝離你的視圖,就是我所看到的所有視圖都是通過聲明方式完成的(MXML),並且只使用Skin類來蒙皮化View子類,您只能通過大多數skinnableContainer皮膚中的contentGroup添加一層層次結構。

如果您使用的是spark.components.View,那麼您使用的是與SkinnableContainer相關的皮膚。你可能認爲這不是一個簡單的小組。

我不知道,我有點不知道該把注意力集中在哪裏。我確信性能影響(如果有的話)將在開發階段的後期發揮作用。

0

從目前爲止的經驗來看,您並不看皮膚。你使用ViewNavigatorApplication。首先,創建自定義皮膚:

public class DViewNavigatorApplicationSkin extends ViewNavigatorApplicationSkin 
{ 
    [Embed(source="assets/wine_240.jpg")] 
    protected var cornerImage:Class; 

    public function DViewNavigatorApplicationSkin() 
    { 
     super();    
    } 


    override protected function drawBackground(unscaledWidth:Number, unscaledHeight:Number):void 
    { 
     graphics.beginFill(0x000000); 
     graphics.drawRect(0,0, unscaledWidth, unscaledHeight); 
     graphics.endFill(); 
     var ba:BitmapAsset = new cornerImage() as BitmapAsset; 
     var translateMatrix:Matrix = new Matrix(); 
     translateMatrix.tx = unscaledWidth - ba.width; 
     translateMatrix.ty = unscaledHeight - ba.height; 
     graphics.beginBitmapFill(ba.bitmapData, translateMatrix); 
     graphics.drawRect(unscaledWidth - ba.width + 1, unscaledHeight - ba.height + 1, ba.width, ba.height); 
     graphics.endFill(); 

    } 

drawBackground的內容將圖像停靠在顯示屏的右下角。你可以在這個函數中繪製任何東西。

然後在theme.css:

s|ViewNavigatorApplication 
{ 
    color: #ffffff; 
    focusColor: #ff9999; 
    skinClass: ClassReference("com.domain.skins.mobile.ThemeName.DViewNavigatorApplicationSkin"); 
} 

s|View 
{ 
    backgroundAlpha: 0; 
} 

您的應用程序本身繪製背景圖像。然後使視圖完全透明,以便通過它可以看到背景圖像。

對每個單獨的視圖進行蒙皮可能是可能的,但是到目前爲止,對應用程序進行蒙皮更爲實用。

0

回答這個問題還爲時過晚。實際上,我們可以使用Spark Skin爲View組件蒙皮,沒有任何問題。View只是SkinnableContainer的一個子類(它是SkinnableComponent的子類),所以默認情況下,直接添加到View組件的MXML的任何內容都將被添加到SkinnableContainer的contenGroup中。

我添加了一個例子使用的Spark皮膚對皮膚的觀點:

主要用途:

<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
      xmlns:s="library://ns.adobe.com/flex/spark" applicationDPI="160"> 
<fx:Script> 
    <![CDATA[ 
     import com.accessdigital.core.SimpleView; 
    ]]> 
</fx:Script> 
<fx:Style> 
    @namespace s "library://ns.adobe.com/flex/spark"; 
    @namespace core "com.accessdigital.core.*"; 
    core|SimpleView{ 
     skinClass : ClassReference("skin.view.Skin_SimpleView"); 
    } 
</fx:Style> 
<s:ViewNavigator width="100%" height="100%" 
       firstView="{SimpleView}"> 

</s:ViewNavigator> 
</s:Application> 

視圖類

public class SimpleView extends View 
{ 
    public function SimpleView() 
    { 
     super(); 
    } 

    [SkinPart(required="true")] 
    public var myButton:Button; 

    override protected function createChildren():void{ 
     super.createChildren(); 
     var anotherButton:Button = new Button(); 
     anotherButton.label = "Another button"; 
     anotherButton.addEventListener(MouseEvent.CLICK, onAnotherButtonClick); 
     if(!actionContent){ 
      actionContent = []; 
     } 
     actionContent.push(anotherButton); 
    } 

    protected function onAnotherButtonClick(event:MouseEvent):void 
    { 
     trace("This is another button");    
    } 

    override protected function partAdded(partName:String, instance:Object):void{ 
     super.partAdded(partName, instance); 
     if(instance == myButton){ 
      myButton.addEventListener(MouseEvent.CLICK, onButtonClick); 
     } 
    } 

    protected function onButtonClick(event:MouseEvent):void 
    { 
     trace("This is a simple button");   
    } 
} 

皮膚文件:

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark"> 
<!-- host component --> 
<fx:Metadata> 
    [HostComponent("com.accessdigital.core.SimpleView")] 
</fx:Metadata> 

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

<!-- SkinParts 
name=myButton, type=spark.components.Button, required=true 
name=contentGroup, type=spark.components.Group, required=false 
--> 
<s:Rect width="100%" height="100%"> 
    <s:fill> 
     <s:LinearGradient rotation="90"> 
      <s:GradientEntry color="#666666"/> 
      <s:GradientEntry color="#222222"/> 
     </s:LinearGradient> 
    </s:fill> 
</s:Rect> 
<s:Group id="contentGroup" width="100%" height="100%"> 
    <s:Button id="myButton" label="My Button" horizontalCenter="0" verticalCenter="0"/> 
</s:Group> 
</s:Skin> 

希望它幫助