*blog... kind of... *rss 



navigateToURLAndUpdateStageSize()
Seems like, in Firefox, if you are browsing your 100% 100% website, open a new tab, and go back to the tab of your website the stage.stageHeight doesn't get updated (the stage now has less vertical space because the tab panel appears). It's specially annoying if you have your navigation aligned to the bottom of the stage because it won't show completely until you manually resize the window.

Checked a bit and dispatching and Event.RESIZE event from the Stage, even delayed, doesn't fix it. So it seems to be something else.

I hate these kind of bugs, you don't know if it's a Firefox bug, a swfobject bug or a flash player bug.

Anyway, if you see yourself in this situation, this dirty patch does the job:

package net.hires.utils.net 
{
	import flash.display.Stage;
	import flash.external.ExternalInterface;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;
	import flash.utils.setTimeout;	

	/**
	 * @author mrdoob
	 */
	public function navigateToURLAndUpdateStageSize( request : URLRequest, stage : Stage, window : String = null ) : void
	{
		navigateToURL( request, window );
		setTimeout( function () : void
					{
						if (ExternalInterface.available)
							ExternalInterface.call( "window.resizeBy", "1", "0" );
					},
					1000 );
	}
}

I guess not so many people will mind if the website resizes +1 pixel the browser window.
11 comments

FYI - the bug you are talking about only happens on the PC.
think it's a firebug , when you in css set a small top or left margin it doesn't occur. 0.04 em will do.
I did try that, but didn't seem to fix it in my case :S
To "not so many people will mind if the website resizes +1 pixel the browser window" but cant you then resize it back by -1 pixel?
Yes, at first I though of doing that, but apparently you can't do 2 externalCalls at once, so I should do another setTimeOut, and seemed a bit to much. But it's worth a try :)
You need to use margin-top: 1px
Tried that, didn't work.
The issue is a bit annoying, just wandering if it happens when windowmode is set to either opaque or transparent, not that it's recommendable.
People WILL mind, because almost everyone who is normal surfs the internets with their browser maximized. That simple 1 pixel resize, will now unmaximize my window which is the most annoying thing in the world.
FYI: it's a real Firefox bug that it doesn't dispatch a Event.RESIZE event when the stage is being initiated. Besides that, IE8 has also a problem with rendering flash.

I think this is becoming a major new area of annoyances because it conflicts with the Actionscript API or FP API. But I don't know if this is a Adobe issue or a browser-manufacturer issue?

So, yes it is a bug, but at the browser or an inconsistency with the Flash Player.
another solution is the following:

addEventListener(Event.ADDED_TO_STAGE, added);

private function added(e:Event):void
{
//initiate the stage and all children on top of it
}

OR

you can just after the main-constructor is finished do dispatchEvent(new Event(Event.RESIZE));


BTW: the problem with IE8 is that when it's loaded the stageWidth = 0 if you have that issue do the following:

...
addEventListener(Event.ADDED_TO_STAGE, added);
}

private function added(e:Event):void
{
if(stage.stageWidth == 0 && stage.stageHeight == 0)
{
stage.addEventListener(Event.RESIZE, checkup);
}else{
checkup(null);
}
}
private function checkup(e:Event):void
{
if(stage.stageWidth != 0 && stage.stageHeight != 0)
{
stage.removeEventListener(Event.RESIZE,checkup);
init();
}
}
private function init():void
{
//set stage properties
stage.frameRate = 25;
stage.scaleMode = StageScaleMode.NO_SCALE;
stage.align = StageAlign.TOP_LEFT;
stage.quality = StageQuality.HIGH;
}