通过使用自定义的Spark外观元素Tab键时,空引用 [英] null reference when tabbing through elements with a custom spark skin

查看:129
本文介绍了通过使用自定义的Spark外观元素Tab键时,空引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经简化我的MXML只是2元,一个按钮和一个复选框。该按钮上有一个非常简单的自定义皮肤,但是也有一些只是直接从SWC(BackButtonUp,BackButtonMouseover和BackButtonClick)装载3种状态。一切都显示了罚款,如果你使用的是鼠标的工作原理。如果你通过TAB的一切,当它崩溃的。

我已编译的Flex SDK的4.5和4.5.1。既得到相同的结果。有在任的设计模式或对动作本身没有任何警告/错误。我不知道什么是错误的,因为堆栈跟踪给我没有我自己的code。

如果我改变我的皮肤是公正< S:矩形> 的对象,那么一切工作正常。只有当我使用加载的SWC符号,它会崩溃。

据崩溃与以下异常(按Tab 6次后):

 类型错误:错误#1009:无法访问空对象引用的属性或方法。
在fl.text::TLFRuntimeTabManager$/onKeyFocusChange()[F:\stage\Flash11.5_Main_325_Stage\main\authortool\Stage\tlfRuntime\fl\text\TLFRuntimeTabManager.as:73]
 

这是我的应用程序MXML:

 < XML版本=1.0编码=UTF-8&GT?;
< S:应用的xmlns:FX =htt​​p://ns.adobe.com/mxml/2009
           XMLNS:S =库://ns.adobe.com/flex/spark
           的xmlns:MX =库://ns.adobe.com/flex/mx
           宽度=400的高度=400>
    < S:布局>
        &所述氏:BasicLayout />
    < / S:布局>

    &所述氏:按钮X =10Y =10的skinClass =skins.BackButton/>
    < S:复选框X =10Y =100/>
< / S:用途>
 

这是我的自定义皮肤MXML是符号的一个名为.swc的文件名):

 < XML版本=1.0编码=UTF-8&GT?;
&所述氏:SparkButtonSkin
    的xmlns:FX =htt​​p://ns.adobe.com/mxml/2009
    XMLNS:S =库://ns.adobe.com/flex/spark
    的xmlns:FB =htt​​p://ns.adobe.com/flashbuilder/2009
    =了minWidth21=了minHeight21
    中用alpha.disabled =0.5
    XMLNS:地方=*>

    < FX:元数据>
        &其中;![CDATA [[HostComponent(spark.components.Button)]]]≥
    < / FX:元数据>

    <! - 州 - >
    < S:国家>
        < S:国名=向上/>
        < S:国名=而不是/>
        < S:国名=向下/>
        < S:国名=已禁用/>
    < / S:国家>

    <地方:BackButtonUp ID =buttonUpincludeIn =起来,禁用/>
    <地方:BackButtonMouseover ID =buttonOverincludeIn =而不是/>
    <地方:BackButtonClick ID =的buttonDownincludeIn =下/>
&所述; /秒:SparkButtonSkin>
 

解决方案

我在Flash CS5的工作主要是,但我有一个非常类似的问题这一点。从你的code,它看起来像你只设置皮肤的上,下,在和残疾人。当您通过元素标签,它实际上选择它们,但你没有任何设置,因此出现了错误的选择皮肤。尝试设置selectedUpSkin,的selectedDownSkin,selectedOverSkin和selectedDisabledSkin。我认为,应该解决您的问题。

I've simplified my mxml to just 2 elements, a Button and a CheckBox. The button has a very simple custom skin on it, there are 3 states that are just directly loaded from a swc (BackButtonUp, BackButtonMouseover, and BackButtonClick). Everything shows up fine and works if you are using the mouse. If you TAB through everything, that's when it crashes.

I have compiled against the flex sdk 4.5 and 4.5.1. Both give the same results. There are no warnings/errors in either design mode or for the actionscript itself. I have no idea what's wrong because the stack trace gives me none of my own code.

If I change my skin to be just <s:Rect> objects, then everything works fine. It's only when I'm using the loaded swc symbols does it crash.

It crashes with the following exception (after hitting TAB 6 times):

TypeError: Error #1009: Cannot access a property or method of a null object reference.
at fl.text::TLFRuntimeTabManager$/onKeyFocusChange()[F:\stage\Flash11.5_Main_325_Stage\main\authortool\Stage\tlfRuntime\fl\text\TLFRuntimeTabManager.as:73]

This is my application mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" 
           width="400" height="400">
    <s:layout>
        <s:BasicLayout/>
    </s:layout>

    <s:Button x="10" y="10" skinClass="skins.BackButton" />
    <s:CheckBox x="10" y="100" />
</s:Application>

This is my custom skin mxml are names of symbols in a .swc file):

<?xml version="1.0" encoding="utf-8"?>
<s:SparkButtonSkin 
    xmlns:fx="http://ns.adobe.com/mxml/2009" 
    xmlns:s="library://ns.adobe.com/flex/spark" 
    xmlns:fb="http://ns.adobe.com/flashbuilder/2009"
    minWidth="21" minHeight="21" 
    alpha.disabled="0.5" 
    xmlns:local="*" >

    <fx:Metadata>
        <![CDATA[ [HostComponent("spark.components.Button")] ]]>
    </fx:Metadata>

    <!-- states -->
    <s:states>
        <s:State name="up" />
        <s:State name="over" />
        <s:State name="down" />
        <s:State name="disabled" />
    </s:states>

    <local:BackButtonUp id="buttonUp" includeIn="up, disabled"/>
    <local:BackButtonMouseover id="buttonOver" includeIn="over"/>
    <local:BackButtonClick id="buttonDown" includeIn="down"/>
</s:SparkButtonSkin>

解决方案

I work mostly in Flash CS5 but I have had a very similar issue to this. From your code it looks like you're only setting skins for up, down, over and disabled. When you tab through elements it actually selects them but you don't have any of the selected skins set so it errors out. Try setting "selectedUpSkin", "selectedDownSkin", "selectedOverSkin" and "selectedDisabledSkin". I think that should fix your problem.

这篇关于通过使用自定义的Spark外观元素Tab键时,空引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆