7 Replies Latest reply on May 1, 2014 7:04 AM by bmohnsen

    Full Screen - can stage proportions be constrained?

    rafa@mediatech Level 1

      Hi everyone;

      I made a button that allows the user to make the project go full screen & restore to regular size. Is there anyway way that when the screen goes full, the porportions are contrained? I just want to eliminate the screen being enlarged to left an right when used on a widescreen monitor. Below is what I am using to make the screen go full:

       

      on mouseUp me
        (the stage).rect = (the desktopRectList)[1]
        (the stage).drawRect = (the desktopRectList)[1]
      end

       

      Rafa.

        • 1. Re: Full Screen - can stage proportions be constrained?
          Sean_Wilson Adobe Community Professional

          Yes, there is a way - you need to optimise the drawRect to the desktop (probably based on the ratio of the sourceRect):

          on mouseUp me
            dr = (the desktopRectList)[1]
            sr = (the stage).sourceRect
            
            tWidthRatio  = float(dr.width )/sr.width
            tHeightRatio = float(dr.height)/sr.height
            ratio = min(tWidthRatio, tHeightRatio)
            tWidth  = sr.width  * ratio
            tHeight = sr.height * ratio
            tDrawRect = mCenterRectInRect(rect(0, 0, tWidth, tHeight), dr)
            
            (the stage).rect     = (the desktopRectList)[1]
            (the stage).drawRect = tDrawRect
          end
          
          -- #movie script:
          on mCenterRectInRect r1, r2
            return rect(r2.width - r1.width, r2.height - r1.height, r2.width + r1.width, r2.height + r1.height)/2
          end
          
          • 2. Re: Full Screen - can stage proportions be constrained?
            rafa@mediatech Level 1

            Sean,

            That works perfectly!

            Can you explain how you came up with the script? If you have a chance, I am sure you are not sitting around waiting to teach lingo...

             

            I just want to understand it, not just throw it in the project...

             

            Rafa.

            • 3. Re: Full Screen - can stage proportions be constrained?
              Sean_Wilson Adobe Community Professional

              I came up with it by slightly adapting a similar routine I use when swapping sprite.member into a fixed rect on the stage and wanting to maintain the proportions of the member while optimising its use of the available area.

               

              It's a matter of determining, when the width of the stage/member is expanded to the maximum, whether there is still room top and bottom; or when the height is expanded to its maximum whether there is room left on the sides - that's what the min ratio calculation is about. The rest is just determining the optimal rect based on this "best" ratio and centering this rect on the desktop.

              • 4. Re: Full Screen - can stage proportions be constrained?
                Jeff_Soko

                how would you format the code, so you could toggle back to the original resolution?

                • 5. Re: Full Screen - can stage proportions be constrained?
                  Sean_Wilson Adobe Community Professional

                  Given your other posts I suspect you can do everything you want with a combination of window.rect, window.drawRect and window.sourceRect

                  • 6. Re: Full Screen - can stage proportions be constrained?
                    rafa@mediatech Level 1

                    Jeff,

                    I never went as far as trying to make it into a single toggle button... I kind of cheated. I added a:

                     

                    on mouseUp me
                      dr = (the desktopRectList)[1]
                      sr = (the stage).sourceRect
                      
                      tWidthRatio  = float(dr.width )/sr.width
                      tHeightRatio = float(dr.height)/sr.height
                      ratio = min(tWidthRatio, tHeightRatio)
                      tWidth  = sr.width  * ratio
                      tHeight = sr.height * ratio
                      tDrawRect = mCenterRectInRect(rect(0, 0, tWidth, tHeight), dr)
                      
                      (the stage).rect     = (the desktopRectList)[1]
                      (the stage).drawRect = tDrawRect
                      go to the frame +1
                    end
                    

                     

                    to the "on mouseUp me" behavior (notice the "go to the frame +1" line). On the next frame, I have the same button with this behavior:

                     

                    on mouseUp me
                      (the stage).rect = rect(295, 288, 935, 786)
                      (the stage).drawRect = rect(0, 0, 644, 503)   
                      go to the frame -1
                    end
                    

                     

                    Which returns the project to its native resolution. In my project it is a simple single section that needed to have this feature. Like I said, I am sure on the programming world this solution must be frowned uppon, but it DOES work... If your project is more complicated, with more sections, I wouldn't recommend this solution.

                     

                    Also, I created my buttons, logos and graphics in Flash, so that when the screen was enlarged, they wouldn't pixelate. If you use this solution with jpgs, pngs or text from Director, when enlarged, it wouldn't look right.

                     

                    Rafa.

                    • 7. Re: Full Screen - can stage proportions be constrained?
                      bmohnsen

                      Does this work for iOS devices?