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

    cannot pass color info


      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







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

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


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

         horizontalCenter="0" verticalCenter="0">





      import mx.events.FlexEvent;



      public var HEDcompleteMAT20requestX:Number = 0;


      public var HEDBC:String = "green";






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


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









        • 1. Re: cannot pass color info

          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