Flex - Custom preloader IE stageWidth - stageHeight problem fixed
February 15th, 2008 by
Jaap Kooiker
My…my…my…
Internet Explorer is like….bad for your health (but you already know that)
In one of the projects I was working on, we used the custom preloader class by Jesse Warden. This way we were able to define our own preloader and it works great, but ofcours not in IE. The alignment in IE doesn’t seem to work after a refresh - or not even at all. This doesn’t happen in any other respectable browser and when using the default flex html template. But we use SWFObject in our projects and then the problem occurs (again only in IE). For the record…it isn’t a SWFObject problem.
After placing a resize event listener on the stage the following occurs.
For some weird reason IE triggers a Resize event at a point when stage width and height is still zero. And at init both width and height are also zero. These 2 resize events aren’t dispatched in for instance FireFox. So no problem there : )
To solve this IE problem (yes…just so you know that’s an IE problem) a resize eventListener has to be declared in the set preloader method (see sample below). Then a modification in the centerPreloader has to be made.
Jesse placed :
x = (stageWidth / 2) - (clip.width / 2);
y = (stageHeight / 2) - (clip.height / 2);
instead use the following:
x = (stage.stageWidth / 2) - (clip.width / 2);
y = (stage.stageHeight / 2) - (clip.height / 2);
And there you go…now it works fine, even in IE : )
Posted in Actionscript 3.0, Components, Did you know?, Flex |
February 15th, 2008 at 1:41 pm
This is the good-shit.. Keep up the good work!!
September 3rd, 2008 at 5:04 pm
score! I’ve been dealing with resolving this issue for too long. It included Firefox 3 and having been chasing a solution around. It seems like a bug in swfObject. thanks!
January 15th, 2010 at 3:27 pm
[…] the ’stage’ property (see blog jaap kooker). And unhide the preloader if we get a valid value for the stage […]
January 15th, 2010 at 3:34 pm
Hi, I tried your solution but it worked only partly for me.
I added some code so that it works, at least for me.
The main idea is that the function that centers the preloader is called each time an progress event is caught.
See also:http://tjoadesign.nl/blog/?p=83
January 15th, 2010 at 5:41 pm
@Eugene This fixes the “page refresh loader in left upper corner” problem. Cool!