2012-03-20 58 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> 

希望它帮助