How to add multiple skin states to SkinnableContainerSkin so that can switch among states

Hi All,
I have a xml which represents 2 views of SkinnableContainer, xml being parsed and converted to ui elements and stored into 2 array variables based on display property of the tag
initially adding 1 set of array element to Container
whenever a button clicked to show different set of array elements, calling removeAllElements() and adding different set of elements from 2nd array
Can somebody help me converting this application to utilize "Skin States"  feature
Sorry, Could not find way to attach demo project, copied code bellow
Thanks in advance...
/src/ContainerDemo.mxml
     /com.containerdemo.controls
          ButtonControl.as
          ContainerControl.mxml
          CustomContainer.as
          CustomControls.mxml
          IControl.as
          ParentControl.mxml
     /com.containerdemo.skins
          ButtonControlSkin.mxml
          CustomContainerSkin.mxml
     /com.containerdemo.utils
          XmlUtil.as
ContainerDemo.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"
                                 minWidth="700" minHeight="500"
                                 xmlns:controls="com.containerdemo.controls.*">
          <s:VGroup paddingBottom="20" paddingLeft="20"
                                paddingRight="20" paddingTop="20" gap="20"
                                horizontalCenter="0">
                    <s:Label text="Flex states demo" fontSize="30"/>
                    <controls:ParentControl id="pc" />
          </s:VGroup>
</s:Application>
XmlUtil.as
package com.containerdemo.utils {
          import com.containerdemo.controls.ButtonControl;
          import com.containerdemo.controls.ContainerControl;
          import com.containerdemo.controls.CustomContainer;
          import com.containerdemo.controls.IControl;
          public class XmlUtil {
                    public static var ELEMENTS:Object = {
                              "buttonElement": ButtonControl,
                              "containerElement": ContainerControl
                    public static function parse(xml:XML):IControl {
                              var name:String = xml.name();
                              var clazz:Class = ELEMENTS[name];  
                              var elem:IControl = new clazz();
                              elem.parse(xml);
                              return elem;
CustomContainerSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
                               xmlns:s="library://ns.adobe.com/flex/spark"                               
                               xmlns:mx="library://ns.adobe.com/flex/mx">
          <fx:Metadata>
                    [HostComponent("com.containerdemo.controls.CustomContainer")]
          </fx:Metadata>
    <s:states>
        <s:State name="normal" />
        <s:State name="disabled" />
    </s:states>
          <s:Group id="rectGroup">
                    <s:Rect left="0" right="0" top="0" bottom="0" radiusX="8" radiusY="8">
                              <s:stroke>
                                        <s:SolidColorStroke weight="2" color="#FF0000" alpha="0.8" />
                              </s:stroke>
                    </s:Rect>
                    <s:HGroup top="10" left="10" right="10" gap="4">
                              <s:Label id="containerLabel" text="{this.hostComponent.label}" />
                              <s:Button id="compOrExpButton" label="{this.hostComponent.btnLabel}" />
                              <mx:Spacer width="100%" />
                    </s:HGroup>
                    <s:Group id="contentGroup" left="16" right="16" top="32" bottom="32" />
          </s:Group>
</s:SparkSkin>
ButtonControlSkin.mxml
<?xml version="1.0" encoding="utf-8"?>
<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"
                               minWidth="21" minHeight="21" alpha.disabled="0.5">
          <fx:Metadata>
                    [HostComponent("com.containerdemo.controls.ButtonControl")]
          </fx:Metadata>
    <s:states>
        <s:State name="up" />
        <s:State name="over" />
        <s:State name="down" />
        <s:State name="disabled" />
    </s:states>
          <s:Label id="labelDisplay"
             textAlign="center"
             verticalAlign="middle"
             maxDisplayedLines="1" minWidth="20"
             horizontalCenter="0" verticalCenter="1"
             left="10" right="10" top="2" bottom="2">
    </s:Label>
</s:SparkSkin>
ParentControl.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx"
                     xmlns:controls="com.containerdemo.controls.*"
                     creationComplete="group1_creationCompleteHandler(event)">
          <fx:Declarations>
                    <fx:XML id="compXml" xmlns="">
                              <elems>
                                        <buttonElement id="b1" label="Element1" />
                                        <containerElement id="c2" label="Container2" display="comp">
                                                  <comp>
                                                            <buttonElement id="c2b1" label="Element5 (Comp)" />
                                                            <buttonElement id="c2b2" label="Element6 (Comp)" />
                                                            <containerElement id="c2c1" label="Container c2c1" display="comp">
                                                                      <comp>
                                                                                <buttonElement id="c2c1b1" label="Element c2c1b1 (Comp)" />
                                                                                <buttonElement id="c2c1b2" label="Element c2c1b2 (Comp)" />
                                                                      </comp>
                                                            </containerElement>
                                                            <containerElement id="c2c2" label="Container c2c2" display="comp">
                                                                      <comp>
                                                                                <buttonElement id="c2c2b1" label="Element c2c2b1 (Comp)" />
                                                                                <buttonElement id="c2c2b2" label="Element c2c2b2 (Comp)" />
                                                                      </comp>
                                                            </containerElement>
                                                  </comp>
                                        </containerElement>
                                        <buttonElement id="b3" label="Element7" />
                              </elems>
                    </fx:XML>
                    <fx:XML id="expXml" xmlns="">
                              <elems>
                                        <buttonElement id="b1" label="Element1" />
                                        <containerElement id="c2" label="Container2" display="exp">
                                                  <comp>
                                                            <buttonElement id="c2b2" label="Element5 (Comp)" />
                                                            <buttonElement id="c2b2" label="Element6 (Comp)" />
                                                            <containerElement id="c2c1" label="Container c2c1" display="exp">
                                                                      <comp>
                                                                                <buttonElement id="c2c1b1" label="Element c2c1b1 (Comp)" />
                                                                                <buttonElement id="c2c1b2" label="Element c2c1b2 (Comp)" />
                                                                      </comp>
                                                                      <exp>
                                                                                <buttonElement id="c2c1b3" label="Element c2c1b3 (Exp)" />
                                                                                <buttonElement id="c2c1b4" label="Element c2c1b4 (Exp)" />
                                                                      </exp>
                                                            </containerElement>
                                                            <containerElement id="c2c2" label="Container c2c2" display="comp">
                                                                      <comp>
                                                                                <buttonElement id="c2c2b1" label="Element c2c2b1 (Comp)" />
                                                                                <buttonElement id="c2c2b2" label="Element c2c2b2 (Comp)" />
                                                                      </comp>
                                                                      <exp>
                                                                                <buttonElement id="c2c2b3" label="Element c2c2b3 (Exp)" />
                                                                                <buttonElement id="c2c2b4" label="Element c2c2b4 (Exp)" />
                                                                      </exp>
                                                            </containerElement>
                                                  </comp>
                                                  <exp>
                                                            <containerElement id="c4" label="Container4" display="comp">
                                                                      <comp>
                                                                                <buttonElement id="c4b1" label="Element 555(Comp)" />
                                                                                <buttonElement id="c4b2" label="Element 655 (Comp)" />
                                                                      </comp>
                                                                      <exp>
                                                                                <buttonElement id="c4b3" label="Element 335 (Exp)" />
                                                                                <buttonElement id="c4b4" label="Element 126 (Exp)" />
                                                                      </exp>
                                                            </containerElement>
                                                  </exp>
                                        </containerElement>
                                        <buttonElement id="b3" label="Element7" />
                              </elems>
                    </fx:XML>
          </fx:Declarations>
          <fx:Script>
                    <![CDATA[
                              import mx.events.FlexEvent;
                              protected function group1_creationCompleteHandler(event:FlexEvent):void {
                                        this.customControls.parse(compXml);
                    ]]>
          </fx:Script>
          <controls:CustomControls id="customControls" />
</s:Group>
IControl.as
package com.containerdemo.controls
          import mx.core.IVisualElement;
          public interface IControl extends IVisualElement {
                    function parse(xml:XML):void;
CustomControls.mxml
<?xml version="1.0" encoding="utf-8"?>
<s:Group xmlns:fx="http://ns.adobe.com/mxml/2009"
                     xmlns:s="library://ns.adobe.com/flex/spark"
                     xmlns:mx="library://ns.adobe.com/flex/mx"
                     implements="com.containerdemo.controls.IControl">
          <fx:Script>
                    <![CDATA[
                              import com.containerdemo.utils.XmlUtil;
                              public function parse(xml:XML):void {
                                        for each (var child:XML in xml.children()) {
                                                  var e:IControl = XmlUtil.parse(child);
                                                  this.addElement(e);
                    ]]>
          </fx:Script>
          <s:layout>
                    <s:HorizontalLayout verticalAlign="middle" gap="15"
                                                                      paddingLeft="16" paddingRight="16"
                                                                      paddingTop="16" paddingBottom="16" />
          </s:layout>
</s:Group>
CustomContainer.as
package com.containerdemo.controls
          import com.containerdemo.skins.CustomContainerSkin;
          import com.containerdemo.utils.XmlUtil;
          import flash.events.MouseEvent;
          import mx.collections.ArrayCollection;
          import spark.components.Button;
          import spark.components.Group;
          import spark.components.SkinnableContainer;
          public class CustomContainer extends SkinnableContainer implements IControl {
                    [SkinPart(required="true")]
                    public var compOrExpButton:Button;
                    [SkinPart(required="true")]
                    public var rectGroup:Group;
                    private var dispState:String;
                    private var _label:String;
                    private var _cid:String;
                    private var compControls:ArrayCollection;
                    private var expControls:ArrayCollection;
                    public function CustomContainer() {
                              this.setStyle("skinClass", Class(CustomContainerSkin));
                    public function parse(xml:XML):void {
                              this.compControls = null;
                              this.expControls = null;
                              compControls = new ArrayCollection;
                              expControls = new ArrayCollection;
                              this.dispState = xml.@display;
                              this.label = xml.@label;
                              this.cid = xml.@id;
                              for each (var child:XML in xml.comp.children()) {
                                        var e:IControl = XmlUtil.parse(child);
                                        this.compControls.addItem(e);
                                        //trace((e is ButtonControl).label);
                              for each (var child1:XML in xml.exp.children()) {
                                        var e1:IControl = XmlUtil.parse(child1);
                                        this.expControls.addItem(e1);
                                        //trace((e1 as ButtonControl).label);
                              showControls();
                    [Bindable]
                    public function set cid(value:String):void {
                              this._cid = value;
                    public function get cid():String {
                              return this._cid;
                    public function showControls():void {
                              if (this.dispState == "comp") {
                                        showCompControls();
                              } else {
                                        showExpControls();
                    public function showCompControls():void {
                              if (this.numElements >0)
                                        this.removeAllElements();
                              for each (var e:IControl in compControls) {
                                        this.addElement(e);
                              this.btnLabel = "Exp";
                              this.invalidateSkinState();
                    public function showExpControls():void {
                              if (this.numElements >0)
                                        this.removeAllElements();
                              for each (var e:IControl in expControls) {
                                        this.addElement(e);
                              this.btnLabel = "Comp";
                              this.invalidateSkinState();
                    public function get ownerContainer():CustomContainer {
                              return this.owner as CustomContainer;
                    public var b:Boolean = true;
                    public function displayCompOrExpControls(event:MouseEvent):void {
                              if (this.btnLabel == "Exp") {
                                        if (b) {
                                                  this.reParse();
                                                  b = false;
                                        } else {
                                                  this.showExpControls();
                              } else {
                                        this.showCompControls();
                    public function reParse():void {
                              /*if (this.owner && (this.owner is CustomContainer))
                                        (this.owner as CustomContainer).reParse();
                              else {*/
                                        var xml:XML = this.parentApplication.pc.expXml;
                                        var expXml:XMLList = xml.descendants().(attribute("id") == this.cid);
                                        this.parse(expXml[0]);
                    private var _btnLabel:String;
                    public function get btnLabel():String {
                              return this._btnLabel;
                    [Bindable]
                    public function set btnLabel(value:String):void {
                              this._btnLabel = value;
                    public function get label():String {
                              return this._label;
                    [Bindable]
                    public function set label(value:String):void {
                              this._label = value;
                    override protected function partAdded(partName:String, instance:Object):void {
                              super.partAdded(partName, instance);
                              if (instance == this.compOrExpButton)
                                        this.compOrExpButton.addEventListener(MouseEvent.CLICK, displayCompOrExpControls, false, 0, true);
                    override protected function partRemoved(partName:String, instance:Object):void {
                              super.partRemoved(partName, instance);
                              if (instance == compOrExpButton)
                                        this.compOrExpButton.removeEventListener(MouseEvent.CLICK, displayCompOrExpControls, false);
ContainerControl.mxml
<?xml version="1.0" encoding="utf-8"?>
<controls:CustomContainer xmlns:fx="http://ns.adobe.com/mxml/2009"
                                                              xmlns:s="library://ns.adobe.com/flex/spark"
                                                              xmlns:mx="library://ns.adobe.com/flex/mx"                                                              
                                                              xmlns:controls="com.containerdemo.controls.*">
          <controls:layout>
                    <s:HorizontalLayout gap="20"
                                                                      paddingLeft="16" paddingRight="16"
                                                                      paddingBottom="16" paddingTop="16" />
          </controls:layout>
</controls:CustomContainer>
ButtonControl.as
package com.containerdemo.controls
          import com.containerdemo.skins.ButtonControlSkin;
          import spark.components.Button;
          public class ButtonControl extends Button implements IControl {
                    public function ButtonControl() {
                              this.setStyle("skinClass", Class(ButtonControlSkin));
                    public function parse(xml:XML):void {
                              this.label = xml.@label;

Could somebody help me?

Similar Messages

  • Which font and how to add a chinese font into font book that can be used in CS6 programs

    I am wondering which chinese fonts are useable for Mac OS X. Which to buy and how to use. Should I use Font Pack or other programs to get the font to be used. Any advice is useful. Thank you

    Are you planning on using the Chinese language in Illustrator?  Or, do you just want a Chinese looking font, but using the English language?  I use Font Agent Pro for font management.  It allows you to install the font, view it and print a sample.  You can look for Chinese looking fonts online ( i.e., myfonts.com ).  As far as Chinese fonts themselves, I have no clue.

  • How to add multiple users to a role in ECC 6.0

    How to add multiple users (say 1000) to a role in ECC 6.0?

    Hi
    You can actually add multiple users to a role using transaction SU01. From SU01, use the menu Environment->Mass Changes.
    Here you can manually add the users, select them by address or authorisation data. Once you have your user list, you can then add or remove roles and/or profiles.
    Secondly , You can use SU10 to do mass changes to multiple users including role assignments per logical systems
    Also check the following link:
    http://www.sap-img.com/bc021.htm
    I hope this should do it
    regards
    Chen

  • How to add multiple table when creating add on using b1de

    Hi all,
    Plz help me
    How to add multiple table when creating add on using b1de.
    Thanks

    Hi dns_sap,
    Can you explain a little better what you are trying to accomplish? Is it to create UserTables and UserFields in the database, when the addon runs the first time?
    If so, you can use the following code
    Add User Table
            Try
                Dim lRetCode As Long
                Dim oUDT As SAPbobsCOM.UserTablesMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserTables)
                oUDT.TableName = TableName
                oUDT.TableDescription = TableDescription
                oUDT.TableType = TableType
                lRetCode = oUDT.Add
                '// Check for error when adding the Table: if lRetCode = 0 the table was created; if lRetCode = -2035 the table already exisits
                If lRetCode <> 0 Then
                    oApplication.MessageBox("Error: " & lRetCode.ToString & ", " & oCompany.GetLastErrorDescription)
                End If
            Catch ex As Exception
                oApplication.MessageBox(oCompany.GetLastErrorDescription)
            Finally
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUDT)
                oUDT = Nothing
                lRetCode = Nothing
                GC.Collect()
            End Try
    Add User Field
    Try
                Dim lRetCode As Long
                Dim oUDF As SAPbobsCOM.UserFieldsMD = oCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.oUserFields)
                oUDF.TableName = TableName
                oUDF.Name = FieldName
                oUDF.Description = FieldDescription
                oUDF.Type = FieldType
                lRetCode = oUDF.Add
                '// Check for error when adding the field: if lRetCode = 0 the field was created; if lRetCode = -2035, the field already exists
                If lRetCode <> 0 Then
                    oApplication.MessageBox("Error: " & oCompany.GetLastErrorCode & ", " & oCompany.GetLastErrorDescription)
                End If
            Catch ex As Exception
                oApplication.MessageBox(oCompany.GetLastErrorDescription)
            Finally
                System.Runtime.InteropServices.Marshal.ReleaseComObject(oUDF)
                oUDF = Nothing
                lRetCode = Nothing
                GC.Collect()
            End Try
    Regards,
    Vítor Vieira

  • How to add multiple namespaces in XSD ?

    Can anyone tell me how to add multiple namespaces inside an XSD. Or how to import XSD into another XSD ??
    Thanks

    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://xml.ibridge.nl/nl/rsg/domein/3/company" xmlns:alg="http://mynamespace/generic" targetNamespace="http://xml.ibridge.nl/nl/rsg/domein/3/company" elementFormDefault="qualified" attributeFormDefault="unqualified" version="2.1">
         <xs:import namespace="http://mynamespace/generic" schemaLocation="algemeen.xsd"/>
    you define xmlns:alg with a namespace
    and after that use the namespace itself to import a xsd for it

  • How to add multiple columns?

    Using designer API, how to add multiple columns to the repository tables? I want to add number of columns at a time instead of adding column by column.
    Thanks in advance.

    Can you use sqlplus?
    ALTER TABLE table_name ADD (column_name data_type), (Column_name datatype),...
    Check the SQL Reference 11-9.
    Hope this helps.
    Bill Swanson

  • How to add multiple button/choices in  button choice

    HI all ,
            How to add multiple button/choices in  button choice ?

    Initialize a cluster array (CrsrList type) with as many cursors as you think you would ever need.   Setup your cursors dynamically, then delete the unused cursors (array elements) and then update your CursorList property.
    Message Edited by vt92 on 03-20-2009 04:04 PM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    cursors.PNG ‏5 KB

  • How to add multiple images in jinternalframe

    Hi all,
    how to add multiple images to the jinternalframe, at specified location of the pane and resizing the images with specified height and width.
    code examples are highly appreciated.
    Thanks & Regards,
    Abel

    Thanks, it works perfectly. It's a really smart way of fixing the problem too :)
    I also found your toggle button icon classes which is something I've also had a problem with.
    Thanks.

  • How to add multiple audio transitions

    I know how to add multiple video transitions to a whole series of clips, but I want to add a cross fade to every audio clip in the sequence....how can I do this if at all, or is it not possible? Thanks

    I'm suspecting that you don't have the destination tabs set correctly when you drag the audio clips to the canvas overlays.
    Destination & Source tabs are the tabs located at the left side of the timeline. When you want to add audio cross fades to your audio clips, do the following:
    1. Set the played at the beginning of the sequence.
    2. Click the video source tab to disconnect it from the video track.
    3. Verify that the audio source tabs are connected to the audio tracks that you want the audio edited to.
    4. Select your audio clips.
    5. Drag the selected audio clips to the Overwrite with Transition overlay in the canvas.

  • How to add multiple test conditions in 'test' attribute expression of xsl:if tag

    Hi all,
    How to add multiple test conditions in 'test' attribute expression of <xsl:if> tag ?
    I have 2 parameters and I want To skip the massage if this 2 conditions happened I tried to write it :
            <xsl:when test="($TransferToCompany = 0 and $ObjectInclide=1 )">
            <b1im_skip xmlns="" info=" Obect Will Not Transfer To company">
            </b1im_skip>
          </xsl:when>
    But I get an error while I am trying to transfer The object (Account) true B1if
    I am working with SBO 9 PL 13
    thank you
    shachar

    Hi saado
    Check this link:
    http://stackoverflow.com/questions/318875/can-you-put-two-conditions-in-an-xslt-test-attribute
    Kind regards,
    Radek

  • How to add multiple child dialog in a singel page of dialog in ms crm2013

    Hi All,
    How to add multiple child dialogs in a page in dialog in online MS CRM 2013. I am able to add dialogs one at the end of the page. I am not able to add single / multiple dialogs in between the page.
    As per my requirement there is multiple conditions , based on the outcome of condition respective child dialogs need to be linked in a page. Any solution ?
    Thanks
    Shankar.B

    Hi,
           As far as I know this is not possible with OOTB Dialoge in the current version. However there are 3rd party tools like TK Dialogs which provide this feature. Here is the link for the tool and few comparison as to when
    to use OOTB v/s TK Dialog.
    http://www.teamknowledge.co.uk/microsoft-crm.php
    http://garethtuckercrm.com/2012/07/11/tk-dialogs-vs-microsoft-crm-dialogs/
    Hope this helps.
     Minal Dahiya
    blog : http://minaldahiya.blogspot.com.au/
    If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

  • How to add (multiple) cursors programmatically in an XY graph?

     how to add (multiple) cursors programmatically in an XY graph?
    I am building an XY graph. then I would like to add cursors at certain locations (positioned on x axis) I determine through a program.
    How can I add cursors programatically?
    Thank you.

    Initialize a cluster array (CrsrList type) with as many cursors as you think you would ever need.   Setup your cursors dynamically, then delete the unused cursors (array elements) and then update your CursorList property.
    Message Edited by vt92 on 03-20-2009 04:04 PM
    "There is a God shaped vacuum in the heart of every man which cannot be filled by any created thing, but only by God, the Creator, made known through Jesus." - Blaise Pascal
    Attachments:
    cursors.PNG ‏5 KB

  • How to Add multiple entry to the group policy security filtering

    How to Add multiple entry to the group policy security filtering
    Is there any way we can add multiple entry to the Domain group policy Security filtering tab.Currently its not allowing to add more then one entry at a time.
    Getting Error like "only one name can be entered,and the name cannot contain a semicolon.Enter a valid name"

    Hi
    Are you trying to add more users or groups through Group Policy Management Security Filtering tab?
    Try right clicking on the policy and then edit
    Then in Editor Right click on the name of the policy and Properties
    Security tab and add user or group from this tab. Just make sure if you are adding user or groups "Select this object type" has
    the correct option also "From this Location" is set to your entire directory not the local server.
    Update us with the above.
    Thanks

  • How to add multiple devices to find my iPhone app

    I am trying to add several iphone devices so I can keep track of kids phone. Does anyone know how to add multiple phones?

    Welcome to the Apple Community.
    settings > iCloud > Find my Phone on each device.

  • Does anyone know how to add multiple pictures to a single frame in iMovie?

    Does anyone know how to add multiple pictures to a single frame in iMovie?

    Maybe you would be better off posting this in the iPhoto or iDVD categories of the forums.
    http://discussions.apple.com/category.jspa?categoryID=143
    http://discussions.apple.com/category.jspa?categoryID=128
    The answer to your question depends on what you ant to do with the DVD.
    Do you want a DVD menu, slide show etc.
    iPhoto will allow you to burn straight to a DVD. Just select the album you want to burn then go to share in the tool bar and select Burn.

Maybe you are looking for