2 Replies Latest reply on Dec 20, 2009 2:25 PM by BasilGr

    Component's state changes on mouse over without event


      I've created some components in flash catalyst and i've trasfered the project over to Flash Builder. I created some custom code and i added an mouse click event on a button that changes the state of one of the components.

      I have 2 states on that component defined like this:


      <s:ItemRenderer xmlns:s="library://ns.adobe.com/flex/spark" xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:graphics="assets.graphics.*" xmlns:mx="library://ns.adobe.com/flex/halo">
              <s:State name="hidden"/>
              <s:State name="visible"/>




      The click event is defined like this


      protected function nomos_click(event:MouseEvent):void


      When i click on the button the state changes as expected to "visible". But as soon as i move my mouse over the the component, it changes state back to "hidden". I scanned all of my code and no other events exist, especially a mouse over or mouse move event.


      Can anyone explain to my why something like this is happening? I've already spent 2 days trying to figure out what the hell is going on.



        • 1. Re: Component's state changes on mouse over without event
          rfrishbe Level 3

          ItemRenderers have a lot of interaction code built-in.  It adds mouseover event listeners for you automatically.  It will also draw

          the highlight color for you (atleast in newer builds), unless you set atuoDrawBackground="false".  You could customize the ItemRenderer to do what you want.  In this case, you'd specifically set autoDrawBackground="false" and override getCurrentRendererState() to return only "hidden" or "visible".


          That said, I think what you want is simpler.  Rather than using an ItemRenderer, try using a DataRenderer.  It doesn't have a lot of this interaction baked in and might be easier for you.


          Hope that helps,


          • 2. Re: Component's state changes on mouse over without event
            BasilGr Level 1


            Changing ItemRenderer to DataRenderer did the trick.


            I didn't have any luck locating autoDrawBackground="false" or getCurrentRendererState() as properties of the ItemRenderer but since there seems to make no difference on my project, i doesn't matter.


            Thanks rfrishbe