0 Replies Latest reply on Aug 7, 2010 3:55 PM by elekwent

    Inconsistencies between an MXML tag instance's properties and an Actionscript instance's properties

    elekwent

      Hi everyone!  I've been using the SDK for several months, but I've only been using Flash Builder for a few weeks.  I finished the Flex In a Week videos and exercises a few days ago, and since then I've been playing around with the accompanying exercises.

       

      My question specifically refers to the PanelSkin.mxml file from 'Exercise 5.6: Creating custom skin properties'.  In this example, the function initTitleSkin() sets the 'headerSkinColor.color' property to a value passed from the main application:

       

       

      <?xml version="1.0" encoding="utf-8"?>

      <s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"

          xmlns:mx="library://ns.adobe.com/flex/mx"

          xmlns:s="library://ns.adobe.com/flex/spark"

          creationComplete="initTitleSkin()">

       

          <s:states>

              <s:State name="normal" />

              <s:State name="disabled" />

          </s:states>   

       

          <fx:Metadata>

                     [HostComponent("components.EmployeePortalPanel")]

         </fx:Metadata>

        

          <fx:Script>

              <![CDATA[

       

                  private function initTitleSkin():void

                  {

                      headerSkinColor.color = hostComponent.panelTitleColor;

                  }

       

              ]]>

          </fx:Script>

       

       

      <s:Rect radiusX="4" radiusY="4" height="100%" width="100%" >

           <s:fill>

                <mx:SolidColor id="panelSkin" color="#E8E8E8"/>

            </s:fill>

      </s:Rect>

       

       

      <s:Path winding="nonZero" data="M 0.016 0.012 L 0.016 23.354 L 287.419 23.354 L 287.408 12.012 C 287.408 5.385 282.035 0.012 275.408 0.012 L 0.016 0.012 Z">

       

           <s:fill>

                <s:SolidColor id="headerSkinColor"/>

           </s:fill>

      </s:Path>

       

       

      <s:Label id="titleDisplay" lineBreak="explicit" left="10" right="4" top="2" height="30" verticalAlign="middle" fontWeight="bold"/>

       

       

      <s:Group id="contentGroup" top="23">

      </s:Group>

        

       

      </s:SparkSkin>

       

       

      This code works just fine.  I tried extending this example by setting the 'titleDisplay.color' property in the same way.  The 'titleDisplay' is an instance of the Label class.

       

           private function initTitleSkin():void

                  {

                      headerSkinColor.color = hostComponent.panelTitleColor;

                      titleDisplay.color = hostComponent.panelLabelColor;

                  }

       

      The above code results in the error 'Access of possibly undefined property color through a reference with static type spark.components:Label'.

       

      I set up the custom 'panelLabelColor' property and confirmed the 'hostComponent.panelLabelColor' property is being passed to the custom skin class correctly.  My question is, Why can I set the 'color' property in the MXML Label block, but not from the ActionScript instance.  The Language Reference shows the spark Label has a 'color' property.  Code Assist shows the 'color' property in the MXML block, but not in the ActionScript instance.  Am I missing something simple that's staring me right in the face?  I'm usually pretty good at that.  I'd appreciate any thoughts on this inconsistency.