2 Replies Latest reply on May 26, 2011 5:50 AM by roestigraben

    cannot pass color info

    roestigraben

      Hi all,

       

      I fairly new in Flex, so bear with me.

       

      I created a component based on BorderContainer and wanted to pass various info from the parent application into this component.

      See below code where I took out pretty much everything that has nothing to do with my problem.

       

      I  want to place a bullet on the x axis and pass the x coordinates (HEDcompleteMAT20requestX) and the color of the bullet (HEDBC).

       

      While the x coordinate work perfectly fine, I cannot get the color to work. It stays stubbornly black (probably default value).

       

      many thanks

       

      Peter

       

       

       

       

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

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

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

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

         horizontalCenter="0" verticalCenter="0">

       

       

      <fx:Script>

      <![CDATA[

      import mx.events.FlexEvent;

       

                      [Bindable]

      public var HEDcompleteMAT20requestX:Number = 0;

      [Bindable]

      public var HEDBC:String = "green";

       

       

      ]]>

      </fx:Script>

       

      <s:Ellipse width="14" height="14" x="{HEDcompleteMAT20requestX}" y="20">

      <s:fill>

      <s:SolidColor color="{HEDBC}" />

      </s:fill>

      <s:filters>

      <s:BevelFilter/>

      </s:filters>

      </s:Ellipse>

       

       

      </s:BorderContainer>

        • 1. Re: cannot pass color info
          Filmzaddict Level 1

          inside your components script section define a private variable, then define a public property for it like this:

           

          private var _someColor:uint;

           

          public function set SomeColor(value:uint):void

          {     _someColor = value;     }

          //dont need the get part of the property

           

           

          Inside your component you can use _someColor as you wish, but on the outside you will be able to write:

           

          <MyComponentName SomeColor="0xff0000" /> for example.

           

          About color type you are using, you should probably pass them as hex values representing unsigned integers!

           

          Hope this is of some help!

          • 2. Re: cannot pass color info
            roestigraben Level 1

            most helpful, thanks again