Hi at all,

 

I have got a component(moveThis) on a canvas(canContent), which I want to move on the canvas by clicking the arrow keys.

That works pretty good, as long as the canvas has got no scrollbars!

 

If canContent has scrollbars and I click at first on moveThis to set the focus, pressing an arrow key causes the scrollbars to move as well!!!

Only if I click on canContent first and than click on moveThis it works instantly...

 

 

That is strange, because I call setFocus() explicitly to the component... and so I have no idea why the scrollbars move ???

Has anyone a idea?

 

 

 

 

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

<mx:Application xmlns:mx="http://www.macromedia.com/2003/mxml" xmlns="*"  >

 

 <mx:Script>

                        <![CDATA[

                        var keyMoveAddValue = 10;

                        var keyListener:Object;

 

 

 

            function doKeyMove(event){

                                   //mx.controls.Alert.show(" test ");

                                   //mx.controls.Alert.show("moveThis.getFocus()" + moveThis.getFocus().id);

                                   if (moveThis.getFocus() == moveThis){

                                                          

                                                if (Key.getCode() == (Key.LEFT)){

                                                           moveThis.x -= keyMoveAddValue;

                                                }else if(Key.getCode() == (Key.UP)){

                                                           moveThis.y -= keyMoveAddValue;

                                                }else if(Key.getCode() == (Key.RIGHT)){

                                                           moveThis.x += keyMoveAddValue;

                                                }else if(Key.getCode() == (Key.DOWN)){

                                                           moveThis.y += keyMoveAddValue;

                                                }

                          

                         }

             }

             

             

 

                                    ]]>

                        </mx:Script>

 

 <mx:Canvas id="canContent" width="500" height="500" minHeight="0" backgroundColor="#ffffff" mouseDown="canContent.setFocus()">

                        <mx:Canvas id="moveThis" width="20" height="20" backgroundColor="#aa0000" keyDown="doKeyMove()" mouseDown="moveThis.setFocus()" />

                        <mx:Canvas id="bigThing" x="200" y="100" width="20" height="600" backgroundColor="#00aa00" />

 </mx:Canvas>

 

 

</mx:Application>

 

 

 

 

 

 

 

 

 

 



--
Flexcoders Mailing List
FAQ: http://groups.yahoo.com/group/flexcoders/files/flexcodersFAQ.txt
Search Archives: http://www.mail-archive.com/flexcoders%40yahoogroups.com




YAHOO! GROUPS LINKS




Reply via email to