randomUser56789
randomUser56789

Reputation: 936

How to skin Alert box in flex 4

How do I skin alert box in flex 4? I am not interested in customizing alert box via css, how do I create skin?

For example, for TextInput I would write in css:

s|TextInput
{
    skinClass: ClassReference("skins.TextInputSkin");
}

and in TextInputSkin.mxml

<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark"
    xmlns:fb="http://ns.adobe.com/flashbuilder/2009" 
    alpha.disabledStates="0.5" blendMode="normal">

    <fx:Metadata>
    <![CDATA[ 
        /** 
         * @copy spark.skins.spark.ApplicationSkin#hostComponent
         */
        [HostComponent("spark.components.TextInput")]  
        ...etc..

And get TextInput globally changed.
How do I make something similar for Alert? I can't understand what is host component for alert.

Upvotes: 1

Views: 2446

Answers (2)

shanks
shanks

Reputation: 922

The MX Alert component is not a single control so to speak. It is basically a combination of the panel, label and button components. Try this out, Skin/Style a standard MX Panel component and apply it globally to your application, You will notice that when you try to call the alert component, it is also affected as it would take the form of the style you just applied. You can Skin a Flex 4 panel then make it a custom popup component to achieve the same effect.

Upvotes: 2

merv
merv

Reputation: 76760

The mx.controls.Alert control is an MX component, and for that reason doesn't use the same skinning architecture that Spark components use, which is what your example uses. Frankly, even though Adobe still refers to it as "skinning" (cf., Skinning MX Components), it doesn't seem to resemble the Spark process very much.

I'm not claiming to offer a comprehensive answer (which is why I'm community wiki-ing this), but as far as I can tell, you're not going get around using styles.

The other relevant information you'll probably need to know is that the Alert derives from the mx.containers.Panel class. So to whatever extent you can "skin" a Panel, is the extent to which you're ultimately going to be able to "skin" an Alert.

Upvotes: 1

Related Questions