0

すべてのスタイルプロパティ/値のリストをcssを介してUIComponentのセレクターに適用したいのですが、それらのリストがどこにも見つからないようです。

たとえば、私はBorderContainerを持っていて、CSSはそれにbackgroundColorを与えます:#869ca7; backgroundAlpha:.5;

そして、ActionScript関数からリスト{backgroundColor:#869ca7、backgroundAlpha:.5}を取得したいと思います。しかし、すべてのUIComponentsで機能する抽象的な方法で(つまり、getStyle( "backgroundColor")を呼び出すことはできません)。

私は2つの方法を試しましたが、非常に親密に感じていますが、実際にはリストを取得できません。

  1. UIComponentのstyleDeclarationプロパティを使用して、UIComponentsからプロパティのリストを取得できるはずですが、持っているスタイルプロパティのリストが表示されていないようです。

  2. また、「uiComponent.getStyle(_)」を呼び出すことで値を取得できるはずですが、プロパティ名を知っている必要があります。

あなたが私を助けることができるどんな洞察にも感謝します。

参考までに、CSSStyleDeclarationクラス: http ://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/styles/CSSStyleDeclaration.html

4

1 に答える 1

1

したがって、私の最初の調査では、スタイルプロパティの配列を取得するための直接的な関数呼び出しやリストがないことが示されています。

カスケード配列でプロパティ名を確認するのが唯一の方法だと思います。

参照用のgetStyleのコード:

public function getStyle(styleProp:String):*
{
    var o:*;
    var v:*;

    // First look in the overrides, in case setStyle()
    // has been called on this CSSStyleDeclaration.
    if (overrides)
    {
        // If the property exists in our overrides, but 
        // has 'undefined' as its value, it has been 
        // cleared from this stylesheet so return
        // undefined.
        if (styleProp in overrides &&
            overrides[styleProp] === undefined)
            return undefined;

        v = overrides[styleProp];
        if (v !== undefined) // must use !==
            return v;
    }

    // Next look in the style object that this CSSStyleDeclaration's
    // factory function produces; it contains styles that
    // were specified in an instance tag of an MXML component
    // (if this CSSStyleDeclaration is attached to a UIComponent).
    if (factory != null)
    {
        factory.prototype = {};
        o = new factory();
        v = o[styleProp];
        if (v !== undefined) // must use !==
            return v;
    }

    // Next look in the style object that this CSSStyleDeclaration's
    // defaultFactory function produces; it contains styles that
    // were specified on the root tag of an MXML component.
    if (defaultFactory != null)
    {
        defaultFactory.prototype = {};
        o = new defaultFactory();
        v = o[styleProp];
        if (v !== undefined) // must use !==
            return v;
    }

    // Return undefined if the style isn't specified
    // in any of these three places.
    return undefined;
}
于 2012-12-12T02:51:19.717 に答える