15 Replies Latest reply on May 16, 2009 2:15 PM by IlyaG

    How can I send Scroling commands from action script?

    IlyaG Level 1

      I just set both horizontalScrollPolicy and verticalScrollPolicy off, and I wont that the picture will scroll down when the user move his mouse to the bottom of the screen, I created mouse event that shows me mouse coordination in a text bar all what I have left to do is to give the scrolling command, just can't find it, so I am asking your help, hope you will.

        • 1. Re: How can I send Scroling commands from action script?
          BennyBeta Level 4

          Try using the container's scrollRect property:

           

          The scroll rectangle bounds of the display object. The display object is cropped to the size       defined by the rectangle, and it scrolls within the rectangle when you change the       x and y properties of the scrollRect object.

           

          Does that help?

          Ben

          • 2. Re: How can I send Scroling commands from action script?
            IlyaG Level 1

            I been trying to translate what you are saying to code, but I didn't found it. Can you show me an example?

            • 3. Re: How can I send Scroling commands from action script?
              Flex harUI Adobe Employee

              Usually you can just set verticalScrollPosition or horizontalScrollPosition.

               

              Alex Harui

              Flex SDK Developer

              Adobe Systems Inc.

              Blog: http://blogs.adobe.com/aharui

              1 person found this helpful
              • 4. Re: How can I send Scroling commands from action script?
                IlyaG Level 1

                Great this is working, the only problem is that I don't know what is my correct view. I wont to set up the scrolling only when I cross 3/4 from my view screen, do you know how to do this?

                • 5. Re: How can I send Scroling commands from action script?
                  Gregory Lafrance Level 6

                  See the Capabilities class to examine the screen resolution:

                   

                  The Capabilities class provides properties that describe the system and 
                  player that are hosting a SWF file. For example, a mobile phone's screen might 
                  be 100 square pixels, black and white, whereas a PC screen might be 1000 square 
                  pixels, color. By using the Capabilities object to determine what type of device 
                  a user has, you can provide appropriate content to as many users as possible. 
                  When you know the device's capabilities, you can tell the server to send the 
                  appropriate SWF files or tell the SWF file to alter its presentation. 
                  

                   

                  For example, here is how you can check the user's screen resolution:

                   

                  <?xml version="1.0" encoding="utf-8"?>
                  <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
                    creationComplete="init();">
                    <mx:Script>
                      <![CDATA[
                        private function init():void{
                          trace("screenResolutionX: " + Capabilities.screenResolutionX);
                          trace("screenResolutionY: " + Capabilities.screenResolutionY);
                        }      
                      ]]>
                    </mx:Script>
                  </mx:Application>
                  
                  1 person found this helpful
                  • 6. Re: How can I send Scroling commands from action script?
                    run,ryan! Level 3

                    is this what you mean?

                    if(xxx.verticalScrollMaxPosition > xxx.height * 1/4)
                    {
                         //do scrolling
                    }
                    
                    • 7. Re: How can I send Scroling commands from action script?
                      IlyaG Level 1

                      This is just not my day, I had to do some changes to my application so now I am working with action script, I am creating a canvas there, and an image as his child. I have 1 function for crating and one for moving(here is where I am changing the view using the scrolls).

                       

                      Now suddenly my creating function is not working here how its look like:

                       

                      private var _worldCanvas:Canvas;

                       

                      public function Constractor(mapImage:String)
                              {
                                  _worldCanvas=new Canvas();
                                  var loadMap:Image=new Image();
                                  loadMap.source=mapImage;
                                  loadMap.x=0;
                                  loadMap.y=0;
                                  _worldCanvas.addChild(loadMap);
                                  _worldCanvas.horizontalScrollPolicy=ScrollPolicy.OFF;
                                  _worldCanvas.verticalScrollPolicy=ScrollPolicy.OFF;
                                  Application.application.addChild(_worldCanvas);
                              }

                       

                       

                      I can't get rid of those scrolls, its like application ignoring the "_worldCanvas.verticalScrollPolicy=ScrollPolicy.OFF" command.

                       

                      The second problem is in the Capabilities.ScreenResolutionX. This can tell me what is user resolution are, but I need to know what is his current view as well, so I will know where to scroll.

                      • 8. Re: How can I send Scroling commands from action script?
                        Flex harUI Adobe Employee

                        It might be that the application has sprouted scrollbars and not worldCanvas.  Set breakpoints and see who the parent of the scrollbars are.

                         

                        Note that by creating and adding children you are not following the component lifecycle and thus might run into other issues.  There is a whole chapter on custom component creation involving methods like createChildren().

                         

                        I'm not clear what "view" you are looking for more information on.

                         

                        Alex Harui

                        Flex SDK Developer

                        Adobe Systems Inc.

                        Blog: http://blogs.adobe.com/aharui

                        • 9. Re: How can I send Scroling commands from action script?
                          IlyaG Level 1

                          Ok I am going to keep my server online during this night, so I hope you will be able to see it.

                          this is my server link http://gazmanwars.zapto.org/.

                           

                          In case you missed it, here come a short description of how it looks like:

                           

                          There is a main char that controls the focus over the screen by his movement, when he moves the canvas is scrolled considerate the speed of his move for each direction, horizontal or vertical. There is two problems: one is when you spam mouse clicking you can put him out of the current view point, and the second is when you resizing the view window or if you just have different resolution then me it can put the char out of the focus as well.

                          So I wont to find some way to control this.

                           

                          I really hope that I been clear enough, please tell me if you still don't understand the question.

                           

                          PS

                           

                          My resolution is 1280/960.

                          • 10. Re: How can I send Scroling commands from action script?
                            Flex harUI Adobe Employee

                            The link didn't work for me.  All Flex objects are relative to a stage position.  If you check the parent's coordinates and width/height and use globalToLocal and localToGlobal you can compute whether any particular Flex object is truly visible.

                             

                            Alex Harui

                            Flex SDK Developer

                            Adobe Systems Inc.

                            Blog: http://blogs.adobe.com/aharui

                            • 11. Re: How can I send Scroling commands from action script?
                              IlyaG Level 1

                              First thing here is the link, I am hosting it now on 000space so it will be always online.

                              http://gazman.000space.com/

                               

                              Now about localToGlobal, this can be useful if the user would use full screen adjustment for his browser, then I could see what resolution he got and just fallow his movement, the problem is that you will always have some additional icons as menu bar, favorites bar and so on... and they most be calculated as well.

                               

                              I need to find some way to see the current user working space witch includes only the site it self, I need to find its current location in global position and his width/height as well.

                              • 12. Re: How can I send Scroling commands from action script?
                                Flex harUI Adobe Employee

                                It seems you might be confused about what coordinate spaces are in play.  My screen is of a particular size (say 1200x1024 and the size is available in system.capabilities.  I open a browser window which can be any size, larger or smaller than the screen if I tweak the resize handles properly.  There is no way to find out how big that window is unless you use Javascript.  The browser window opens an HTML page that has a tag in it that hosts the Flash Player plug in.  The HTML is interpreted by the browser and sets up the Flash Player at a certain size.  Usually that's the size of the browser window (minus address bar, menus, toolbars, status bar), but it can be any size, even a small popup calculator that floats over the web-page.  Flash cannot draw outside that area and that area is called the stage and serves as the coordinate system for Flex apps with 0,0 being the topleft so localToGlobal will tell you everything you need to know about places you can use Flex/Flash to draw on the screen.

                                 

                                If they use fullscreen then the coordinate system will be roughly the same, but most of the time, folks won't use it so you'll have to live within the area owned by Flash in the browser which is some subset of the full screen.

                                 

                                Alex Harui

                                Flex SDK Developer

                                Adobe Systems Inc.

                                Blog: http://blogs.adobe.com/aharui

                                • 13. Re: How can I send Scroling commands from action script?
                                  IlyaG Level 1

                                  Well this is just the question, how can I find that stage square? I know it's top left corner coordination, witch is 0,0 but what about the right bottom corner?

                                   

                                  I think that I am going to make the focus fallow my char instead trying to make them going together like it's happening now, the only question that stays unsolved(Even if you can help me to find stage right bottom corner coordination) is how can I know the size of the seen stage at resized window(not maximized window), I think that I just ignore this situation for now.

                                  • 14. Re: How can I send Scroling commands from action script?
                                    Flex harUI Adobe Employee

                                    Try systemManager.screen

                                     

                                    Alex Harui

                                    Flex SDK Developer

                                    Adobe Systems Inc.

                                    Blog: http://blogs.adobe.com/aharui