I didn't run the code, but in reading it I see that the MXML version hooks to 
"rollover" and the AS version hooks to "mouseOver" which would explain the 
difference

 

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On Behalf Of Igor 
Costa
Sent: Monday, April 07, 2008 2:34 PM
To: [email protected]
Subject: Re: [flexcoders] Flex Code Behind issue

 

Very Stange behavior.

 

I´ve tested your code and couldn´t get same error.

 

Log a bug for it.

 

Regards

Igor Costa



 

On 4/6/08, firdosht <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > wrote: 

Hey guys,
                     so I have created a simple flex proj

<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml 
<http://www.adobe.com/2006/mxml> " layout="absolute" themeColor="#0EFF02">




               <mx:Script>

                               <![CDATA[

                                              private function 
onOver(evt:Event):void{

                                                             trace("onOver : " 
+evt.currentTarget );

                                                             
test.setStyle("backgroundColor",0xff00ff);

                                              }

                                              

                                              private function 
onOut(evt:Event):void{




                                                             trace("onOut : " 
+evt.currentTarget );

                                                             
test.setStyle("backgroundColor",0xffff00);

                                              }

                               ]]>

               </mx:Script>

               <mx:Canvas id="test"  x="118" y="136" width="443" height="133" 
themeColor="#099FFF" backgroundColor="#D70000" rollOver="onOver(event);" 
rollOut="onOut(event);">




                               <mx:Button x="39" y="35" label="Button"/>

               </mx:Canvas>

</mx:Application>





So basically all the code above does is changes the backgroundColor of the 
Canvas. It works fine 




Now if I make a MXML Component using the Code Behind Method




















 








<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml 
<http://www.adobe.com/2006/mxml> " layout="absolute" themeColor="#0EFF02" 
xmlns:ns1="item.*">




               <ns1:ListItem x="80" y="48"/>          

</mx:Application>









ListItem.mxml




<item:CListItem xmlns:mx="http://www.adobe.com/2006/mxml 
<http://www.adobe.com/2006/mxml> " width="400" height="300" xmlns:item="item.*">




               <mx:Button x="65" y="61" label="Button"/>             

</item:CListItem>













CListItem.as

package item

{

               import flash.events.MouseEvent;              

               import mx.containers.Canvas;

               import mx.events.FlexEvent;






               public class CListItem extends Canvas

               {

                               public function CListItem()

                               {

                                              super();

                                              
this.addEventListener(FlexEvent.CREATION_COMPLETE, onComponentLoaded);     

                               }

                               

                               private function 
onMouseOver(evt:MouseEvent):void{




                                              trace("CListItem.onMouseOver :");

                                              
this.setStyle("backgroundColor",0xff00ff);                                      
                         

                               }

                               

                               private function onMouseOut(evt:MouseEvent):void{

                                              trace("CListItem.onMouseOut");




                                              
this.setStyle("backgroundColor",0xffff00);                                 

                               }

                               

                               private function 
onComponentLoaded(evt:FlexEvent):void{                                          
                                 

                                              
this.addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);                      
                  

                                              
this.addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);              




                               }                              

               }

}







Now when I mouse over the Button component the onMouseOut function gets called 
and there is a flicker in the backgroundColor.

If I dont use the Code Behind Method then the onMouseOut function does not get 
called when I rollOver the button.






Can anyone explain this strange behavior? 

Thanks



Cheers

Firdosh







 




-- 
----------------------------
Igor Costa
www.igorcosta.com <http://www.igorcosta.com> 
www.igorcosta.org <http://www.igorcosta.org>  

 

Reply via email to