1 Reply Latest reply on May 1, 2011 11:33 AM by Shongrunden

    Is this a bug?

    sebaexpress

      Hi everybody,

       

      I'm currently using flex sdk 4.5 (but it's the same with 4.1 too) and I have the following problem:

       

      I bind the current state of an ItemRenderer to an external object. This object is injected to the mxml view through Robotlegs injector.

       

       

      the view has 4 states, everything works fine as long as I don't roll over the item itself. In this case, without any apparent explanation, the currentState switches to defaultstate even if the bound currentState variable hasn't changed is value. To solve this problem (and prove that the bound state value didn't change) I listen the added event of the button which is created when the state switches to default and force the currentState to switch again to the current value.

       

      It works but it's obviously bad, can somebody tell me what's going on? Thank you!

       

      please have a look at the following code:

      
      
      <s:ItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009"
       xmlns:s="library://ns.adobe.com/flex/spark"
       xmlns:mx="library://ns.adobe.com/flex/mx"
       xmlns:modelviews="it.addme.MVVM.modelviews.*"
       width="150" height="100" autoDrawBackground="true"
       currentState="{modelView.currentState}"
       >
       
       <fx:Script>
       <![CDATA[
       import it.addme.MVVM.modelviews.AddMeButtonPresenter;
      
       [Inject]
       [Bindable]
       public var modelView:AddMeButtonPresenter;
       
       override public function set data(value:Object):void 
       {
       panel.title = value.appName;
       } 
      
       protected function button1_addedHandler(event:Event):void
       {
       currentState = modelView.currentState;
       }
      
       ]]>
       </fx:Script>
       
       <s:states>
       <s:State name="default" />
       <s:State name="USER_UNKNOWN" />
       <s:State name="USER_EXISTS" />
       <s:State name="USER_DOESNT_EXIST" />
       </s:states>
       
       <s:Panel left="0" top="0" width="150" height="100" id="panel">
       <s:Button includeIn="USER_UNKNOWN" label="Checking..." enabled="true" horizontalCenter="0"
       verticalCenter="0"/>
       <s:Button includeIn="USER_EXISTS" label="Unsubscribe" click="modelView.unsubscribe()"
       enabled="true" horizontalCenter="0" verticalCenter="0"/>
       <s:Button includeIn="USER_DOESNT_EXIST" label="Subscribe" click="modelView.subscribe()"
       enabled="true" horizontalCenter="0" verticalCenter="0"/>
       <s:Button includeIn="default" label="..." added="button1_addedHandler(event)"
       horizontalCenter="0" includeInLayout="false" verticalCenter="0"/>
       </s:Panel>
      </s:ItemRenderer>