11 Replies Latest reply on Oct 18, 2007 11:10 AM by clbeech

    stageWidth after resize

    KinseyFobes Level 1
      When I resize the stage during execution stage.stageWidth changes as expected, but the 0,0 coorinate seems to ove. When I trace out the stage.mouseX or mouseY coordinates after maximizing the stage I get negative numbers for the upper left hand corner, and the lower right gives numbers that are too low. For instance my normal stageWidth is 550, but when I maximize I get 1020, but the left side of my stage returns a position of -235 and the right side gives 785 (234 + 785 = 1020). Is there a way to reset the base coordinate, or am I doing something wrong?

        • 1. Re: stageWidth after resize
          Rothrock Level 5
          You know I haven't tried this in AS3 (which I gather from stage.stageWidth instead of Stage.width) and even then I'm no expert on this, but…

          Have you gone into your publish settings and change the HTML setting to left top? Or there might be some way of setting that through the code in AS3?

          Again, I'm not really clear on all this, having not yet done it in AS3. Just some ideas…
          • 2. stageWidth after resize
            clbeech Level 3
            Say, I'm not up with AS3 yet either, but it occured to me ... isn't this what the Stage is suppose to do? From your discription above, it seems as though the Stage did not 'resize' which is just what it's suppose to do, stay the same size and become 'placed' in the center of the window? You'd said that trace the mouse coordinates gives negative values on the left and greater values on the right than the width of the original Stage ... that's how it should be right.

            It seems like the actual 'size' of the Stage should only be changed when implementing the onResize method. Not sure but it seems ...

            just some thoughts :)
            • 3. Re: stageWidth after resize
              KinseyFobes Level 1
              Actually I'm not in html at this point. I'm testing the movie in the Flash environment and using the Flash Player. The stage DOES resize because the stageWidth property changes.

              The problem is as I move objects around the screen I keep them visible by limiting their movement to between 0,0 and the stageWidth. the 0,0 point isn't the top left then all of the other calculations are off and my objects are all shifted down and to the right, going off of the stage.
              • 4. Re: stageWidth after resize
                clbeech Level 3
                Interesting, this must be a AS3 thing. The way I understand it (and I've only just begun to do my reading) is that the Stage is now treated as a DisplayObject or something like that, so then it's interesting that it resizes to the whole visible area, kind of handy really. Maybe you could use an onResize handler to control the 'Stage' size limiting it the size you want and centering it with the display area?

                Again, just thoughts :P
                • 5. Re: stageWidth after resize
                  Rothrock Level 5
                  I'm pretty sure I've always experienced this in the testing environment and/or if you plan on publishing to a projector.

                  Yes the stage does resize, clbeech, the onResize handler just allows you to add code that responds to the event. The event happens and the handler responds.

                  KinseyFobes, if the final target for this is a website then you will have to test in that environment to make sure it is working. if you plan on directly using a swf or projector you will have to do some math.
                  • 6. Re: stageWidth after resize
                    Greg Dove Level 4
                    Whenever I've done stuff in as2 I think I used
                    Stage.align="TL" and

                    These properties still appear to exist for the stage from a quick glance at the as3 docs.
                    I've never experienced exactly what you describe, but I'd perhaps the "TL" part might be important.

                    • 7. Re: stageWidth after resize
                      clbeech Level 3
                      very good, and it's not that I don't buy into that RR, but this does seem to go to the OPs point. It seems odd that items fixed to a position relative tot he original Stage size as set in the Authoring tool, do not change position relative to the 'new' stage size, and mouse coordinates do in fact show negative and positive values that are related to the size of the original stage.

                      So how can it be that the actual 'size' of the Stage changes, yet items positioned to it remain. is there something similar to what's going on in AS3, happening in the background of AS2?

                      Here is a quick example of what I'm saying here, that things remain positioned correctly in relation to the 'original' Stage size and values, but when maximized change thier 'real' cooridnates, but don't register the new system to the mouse.

                      I dunno if that makes sense, here's a test file: FLA
                      • 8. Re: stageWidth after resize
                        KinseyFobes Level 1
                        GWD was VERY close! I had already been using stage.scaleMode=StageScaleMode.NO_SCALE; but I hadn't used the stage.align property. After including stage.align=StageAlign.TOP_LEFT; everything resolved itself.

                        Thanks for everyones responses
                        • 9. Re: stageWidth after resize
                          Greg Dove Level 4
                          Good to hear.
                          StageAlign.TOP_LEFT == "TL" and StageScaleMode.NO_SCALE=="noScale"
                          they're just new constants included in as3 for those values.
                          • 10. Re: stageWidth after resize
                            KinseyFobes Level 1
                            Also make sure you're referencing stage with a lowercase "s" and not the Class name with an uppercase "S". This is true for AS3 not AS2.
                            • 11. Re: stageWidth after resize
                              clbeech Level 3
                              bingo! great GWD and RR, this is great to know, I guess this may have been causing some of the issues I'd run into in the past also, LOL!!! :)