2 Replies Latest reply on Apr 27, 2011 5:35 AM by PaddyMc2010

    ColorTransform Question

    PaddyMc2010

      Hi All,

       

      Quick and im sure very easy question, i am new to flex and coding in general.  I have 3 Images that i want to use as a kind of rollover toolbar.

       

      I want to use the color transform to highlight as they go along the images.  Using the code below this will do exactly what i want when passing the ImageID Search and looks good.  However i need this to be more generic, so i can pass in ImageID into the functions and add the arguments to the mx image mouse over etc.  However when i do this it dosnt like a string to be passed and and generic object will not work either. Can anyone advise how i might be able to go about doing this and passing the appropiate args into my function?

       

      <mx:Image

       

       

      id="Search"

      errorString="S

      earch"

      source="

      @Embed('images/toolbar/find.png')"

      click="searchOnClick()"

      mouseOver="onImageMouseOver()"

      mouseOut="onImageMouseOut()"

      />

       

      public

       

       

       

       

      var myColorTransform:ColorTransform;

      private function onImageMouseOver():void

      {

      myColorTransform =

      new ColorTransform(1,1,1,1,50,50,50);

      Search.transform.colorTransform = myColorTransform;

      }

       

      private function onImageMouseOut():void

      {

      myColorTransform =

      new ColorTransform();

      Search.transform.colorTransform = myColorTransform;

      }

       

       

        • 1. Re: ColorTransform Question
          ipauland

          This should give you a leg up: don't forget to pass the event object and use it to know what object is being targetted.

           

          Haven't tested it.

           

          Paul

           

          <mx:Image

           

           

          id="Search"

          errorString="S

          earch"

          source="

          @Embed('images/toolbar/find.png')"

          click="searchOnClick()"

          mouseOver="onImageMouseOver(event)"

          mouseOut="onImageMouseOut(event)"

          />

           

          var myColorTransform:ColorTransform;

          private function onImageMouseOver(e:MouseEvent):void

           

          {

          myColorTransform =

          new ColorTransform(1,1,1,1,50,50,50);

          e.currentTarget.transform.colorTransform = myColorTransform;

          }

           

          private function onImageMouseOut(e:MouseEvent):void

           

          {

          myColorTransform =

          new ColorTransform();

          e.currentTarget.transform.colorTransform = myColorTransform;

          }

          • 2. Re: ColorTransform Question
            PaddyMc2010 Level 1

            Paul,

             

            Its easy when you know how, You are right on the money and it works a treat, i was trying to pass the actual object and not the event.

             

            Thanks a bunch this is great.

             

            Paddy