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) 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) (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
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...
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.
how would you format the code, so you could toggle back to the original resolution?
Given your other posts I suspect you can do everything you want with a combination of window.rect, window.drawRect and window.sourceRect
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) 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) (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.
Does this work for iOS devices?