-
AS2 Stage size measuring
Hi chaps
Got an odd AS2 problem, basically its quite simple (there's the problem!)
I want to measure the size of the "Flash Player window" for an application (not a browser), so I can't use the normal javascript methods I've used before from the HTML container to measure it.
I also need to use the normal "scaling" features of Flash to fit any possible resolution the app is run in, e.g. showing in letterbox mode on 4:3 etc, the idea is to show alternate content if run on a widescreen or 4:3 aspect screen in the "black bar areas"
E.g. Stage.scaleMode="ShowAll"
I've found some code to return the current size, using a listener.onResize command, but the problem is it only works when you:
a) physically resize the window and
b) if the stage.scaleMode "noScale" is set, which is not what I want to do in this case as I want my content to fit the screen width.
In terms of operation, I want to check the size as the app starts up, and scale it to fit in the normal way.
Strangely even tests like _root.height and _root.width in functions triggered by test buttons in the app also returns the actual "design size" of the flash movie as set in the document settings, which again is no use.
I find it hard to believe that I can't interrogate what physical dimensions the Flash Player window is running under - irrespective of scaling!
Any ideas anyone?
-
Do you mean something like this?
PHP Code:
Stage.align = "TL"; var stageObj = new Object(); var crazy:Number = 0; Stage.addListener(stageObj); stageObj.onResize = function() { crazy = Stage.width; trace(crazy); }; stageObj.onResize(); Stage.addListener(stageObj);
-
Thanks bgregus, but when your code is run the "crazy" parameter still shows the "design size" of 550 (which is the flash document size) when the fullscreen command is added before that, rather than 1920x1200 which is what I'm after when running it on a widescreen monitor.
So its the flash "app window size" I'm after basically. Obviously you can't do fullscreen in the Flash IDE, so you can only see this by running the .swf in the built in flash player after exporting, I added a circle to the stage and a text field to show the value of your variable...
PHP Code:
fscommand("fullscreen", true);
Stage.align = "TL";
var stageObj = new Object();
var crazy:Number = 0;
Stage.addListener(stageObj);
stageObj.onResize = function() {
crazy = Stage.width;
trace(crazy);
};
stageObj.onResize();
Stage.addListener(stageObj);
Last edited by derekcfoley; 10-08-2009 at 05:40 AM.
-
Also unfortunately, the onResize routine you provided an example of only works if you set
PHP Code:
Stage.scaleMode = "noScale";
This is the problem basically, because I want to return the size without stopping the automatic resize that happens on the fullscreen command.
-
OK so if I understand correctly you aren't resizing the browser, you are "full screening" it. When doing this flash isn't picking up the resize.
How about on your fullscreen you check this
PHP Code:
width = System.capabilities.screenResolutionX
height = System.capabilities.screenResolutionY
trace (width);
trace (height);
and then plug those numbers in.
-
fingers crossed btw
-
Been here before and the only solution is to put all of your content into a movie clip, set scaleMode to "noScale" and resize the movie clip to fill the stage in the onResize handler.
..but you've probably solved this months ago!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|