Actionscript 3 Flex Mobile:如何创建外观视图?

Actionscript 3 Flex Mobile:如何创建外观视图?,actionscript-3,apache-flex,skinning,flex4.6,flex-mobile,Actionscript 3,Apache Flex,Skinning,Flex4.6,Flex Mobile,我想知道是否可以为我的Flex移动应用程序创建皮肤视图: 我的ActivityView.as My ActivityViewSkin.mxml(与皮肤相关) [主机组件(“com.corp.views.activity.ActivityView”)] ... 这是移动发展的好方法吗 我该如何在这种皮肤中使用它呢 <s:navigationContent> 多谢各位 安东尼不。 Spark skin未针对移动设备进行优化。你应该使用手机皮。(仅限动作脚本)。我一直在寻找类似的

我想知道是否可以为我的Flex移动应用程序创建皮肤视图:

我的ActivityView.as

My ActivityViewSkin.mxml(与皮肤相关)


[主机组件(“com.corp.views.activity.ActivityView”)]
...
这是移动发展的好方法吗

我该如何在这种皮肤中使用它呢

<s:navigationContent>

多谢各位

安东尼

不。
Spark skin未针对移动设备进行优化。你应该使用手机皮。(仅限动作脚本)。

我一直在寻找类似的信息,但我从文档和博客中推断出的一切都表明,MobileSkin是组件级蒙皮(例如按钮、列表、项目渲染器等)的一种方式,在整个应用程序中会被多次使用

认为可以通过MXML对视图进行蒙皮的另一个原因是,我看到的所有视图代码都是以声明方式(MXML)完成的,通过仅使用Skin类对视图子类进行蒙皮,在大多数skinnableContainer外观中,您只需通过contentGroup再添加一层层次结构

如果您使用的是spark.components.View,那么您使用的是与关联的蒙皮,因为它是SkinnableContainer。这并不像你想象的那样是一个简单的群体


我不知道,我有点不知所措,不知该把精力集中在哪里。我确信性能影响(如果有的话)将在开发阶段的后期出现。

根据目前的经验,您不会忽略这一点。您可以对ViewNavigator应用程序进行蒙皮。首先,创建自定义蒙皮:

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();

    }
牵引架地面的内容将图像固定到显示屏的右下角。你可以在这个函数里画任何东西

然后在theme.css中:

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

s|View
{
    backgroundAlpha: 0;
}
在应用程序本身上绘制背景图像。然后使视图完全透明,以便可以通过它看到背景图像


可以对每个视图进行蒙皮,但到目前为止,对应用程序进行蒙皮似乎更为实际。

回答这个问题有点晚。实际上,我们可以使用Spark Skin对视图组件进行蒙皮,没有任何问题。View只是SkinnableContainer的一个子类(它是SkinnableComponent的子类),因此默认情况下,直接添加到View组件的MXML的任何内容都将添加到SkinnableContainer的ContendGroup

我添加了一个使用Spark skin对视图进行蒙皮的示例:

主要用途:

<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>
皮肤文件:

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

[主机组件(“com.accessdigital.core.SimpleView”)]
希望能有帮助

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